Converts this collection to a capped one.
Converts this collection to a capped one.
import scala.concurrent.{ ExecutionContext, Future } def capColl(coll: reactivemongo.api.bson.collection.BSONCollection)( implicit ec: ExecutionContext): Future[Unit] = coll.convertToCapped(size = 10L, maxDocuments = Some(100))
the size of the collection (number of bytes)
the maximum number of documents this capped collection can contain
Creates this collection.
Creates this collection.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.CollectionMetaCommands def createIfNotExists(coll: CollectionMetaCommands)( implicit ec: ExecutionContext): Future[Unit] = coll.create(failsIfExists = true)
if true fails if the collection already exists (default: false)
Creates this collection.
Creates this collection.
The returned future will be completed, with an error if this collection already exists.
import scala.concurrent.ExecutionContext import reactivemongo.api.CollectionMetaCommands import reactivemongo.api.commands.CommandError def createColl( coll: CollectionMetaCommands)(implicit ec: ExecutionContext) = coll.create().recover { case CommandError.Code(48) => // NamespaceExists println(s"Collection \${coll} already exists") }
Creates this collection as a capped one.
Creates this collection as a capped one.
The returned future will be completed with an error if this collection already exists.
import scala.concurrent.{ ExecutionContext, Future } def capped(coll: reactivemongo.api.bson.collection.BSONCollection)( implicit ec: ExecutionContext): Future[Unit] = coll.createCapped(size = 10, maxDocuments = Some(100))
the size of the collection (number of bytes)
the maximum number of documents this capped collection can contain
If true should automatically add an index on the _id
field. By default, regular collections will have an indexed _id
field, in contrast to capped collections. This MongoDB option is deprecated and will be removed in a future release.
Drops this collection.
Drops this collection.
If the collection existed and is successfully dropped, the returned future will be completed with true.
If failIfNotFound
is false and the collection doesn't exist,
the returned future will be completed with false.
Otherwise in case, the future will be completed with the encountered error.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.CollectionMetaCommands def dropIfNotFound(coll: CollectionMetaCommands)( implicit ec: ExecutionContext): Future[Boolean] = coll.drop(failIfNotFound = true)
the flag to request whether it should fail
Returns an index manager for this collection.
Returns an index manager for this collection.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.CollectionMetaCommands def listIndexes(coll: CollectionMetaCommands)( implicit ec: ExecutionContext): Future[List[String]] = coll.indexesManager.list().map(_.flatMap { idx => idx.name.toList })
Returns various information about this collection.
Returns various information about this collection.
import scala.concurrent.{ ExecutionContext, Future } def getSize(coll: reactivemongo.api.bson.collection.BSONCollection)( implicit ec: ExecutionContext): Future[Double] = coll.stats(scale = 1024).map(_.size)
the scale factor (for example, to get all the sizes in kilobytes)
Returns various information about this collection.
Returns various information about this collection.
import scala.concurrent.{ ExecutionContext, Future } def isCapped(coll: reactivemongo.api.bson.collection.BSONCollection)( implicit ec: ExecutionContext): Future[Boolean] = coll.stats().map(_.capped)
Drops this collection.
Drops this collection.
The returned future will be completed with an error if this collection does not exist.
(Since version 0.12.0) Use drop(Boolean)
Renames this collection.
Renames this collection.
the new name of this collection
if a collection of name to
already exists, then drops that collection before renaming this one
A failure if the dropExisting option is false and the target collection already exists.
(Since version 0.12.4) Use reactivemongo.api.DBMetaCommands.renameCollection on the admin database instead.
A mixin that provides commands about this Collection itself.
(Since version 0.19.8) Internal: will be made private