t

reactivemongo.api.collections

GenericCollection

trait GenericCollection[P <: SerializationPack with Singleton] extends Collection with GenericCollectionWithCommands[P] with CollectionMetaCommands with ImplicitCommandHelpers[P] with InsertOps[P] with UpdateOps[P] with DeleteOps[P] with CountOp[P] with DistinctOp[P] with GenericCollectionWithDistinctOps[P] with FindAndModifyOps[P] with ChangeStreamOps[P] with Aggregator[P] with GenericCollectionMetaCommands[P] with GenericCollectionWithQueryBuilder[P] with HintFactory[P]

A Collection that provides default methods using a SerializationPack (e.g. the default reactivemongo.api.BSONSerializationPack).

Some methods of this collection accept instances of Reader[T] and Writer[T], that transform any T instance into a document, compatible with the selected serialization pack, and vice-versa.

P

the serialization pack

Self Type
GenericCollection[P]
Linear Supertypes
HintFactory[P], GenericCollectionWithQueryBuilder[P], GenericCollectionMetaCommands[P], collections.Aggregator[P], ChangeStreamOps[P], FindAndModifyOps[P], GenericCollectionWithDistinctOps[P], DistinctOp[P], DistinctOpCompat[P], CountOp[P], DeleteOps[P], UpdateOps[P], InsertOps[P], ImplicitCommandHelpers[P], CollectionMetaCommands, GenericCollectionWithCommands[P], Collection, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. GenericCollection
  2. HintFactory
  3. GenericCollectionWithQueryBuilder
  4. GenericCollectionMetaCommands
  5. Aggregator
  6. ChangeStreamOps
  7. FindAndModifyOps
  8. GenericCollectionWithDistinctOps
  9. DistinctOp
  10. DistinctOpCompat
  11. CountOp
  12. DeleteOps
  13. UpdateOps
  14. InsertOps
  15. ImplicitCommandHelpers
  16. CollectionMetaCommands
  17. GenericCollectionWithCommands
  18. Collection
  19. AnyRef
  20. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. sealed trait WatchBuilder[T] extends AnyRef

    A builder for the watch collection helper, which allows to consume the collection's ChangeStream.

    A builder for the watch collection helper, which allows to consume the collection's ChangeStream.

    Definition Classes
    ChangeStreamOps
  2. sealed trait DeleteBuilder extends AnyRef

    Builder for delete operations.

    Builder for delete operations.

    Definition Classes
    DeleteOps
  3. type AggregationFramework = AggregationFramework.type

    Alias for type of the aggregation framework, depending on the type of the collection.

    Alias for type of the aggregation framework, depending on the type of the collection.

    See also

    reactivemongo.api.commands.AggregationFramework

  4. final class Aggregator[T, AC[_] <: Cursor[_]] extends AnyRef
    Definition Classes
    Aggregator
  5. final class AggregatorContext[T] extends AnyRef
    Definition Classes
    Aggregator
  6. final class CollectionQueryBuilder extends GenericQueryBuilder[pack.type]
    Attributes
    protected
    Definition Classes
    GenericCollectionWithQueryBuilder
  7. case class DistinctResult extends Product with Serializable

    Attributes
    protected
    Definition Classes
    DistinctOp
  8. type PipelineOperator = commands.AggregationFramework.PipelineOperator

    Alias for reactivemongo.api.commands.AggregationFramework.PipelineOperator

  9. sealed trait InsertBuilder extends AnyRef

    Builder for insert operations.

    Builder for insert operations.

    Definition Classes
    InsertOps
  10. sealed trait UpdateBuilder extends AnyRef

    Builder for update operations.

    Builder for update operations.

    Definition Classes
    UpdateOps
  11. trait ImplicitlyDocumentProducer extends AnyRef
    Definition Classes
    ImplicitCommandHelpers

Abstract Value Members

  1. abstract val BatchCommands: BatchCommands[pack.type]
    Attributes
    protected
  2. abstract def db: DB

    The database which this collection belong to.

    The database which this collection belong to.

    Definition Classes
    Collection
  3. abstract def name: String

    The name of the collection.

    The name of the collection.

    Definition Classes
    Collection
  4. abstract val pack: P
  5. abstract def withReadPreference(pref: ReadPreference): GenericCollection[P]

    Returns a new reference to the same collection, with the given read preference.

  6. abstract def failoverStrategy: FailoverStrategy

    The default failover strategy for the methods of this collection.

    The default failover strategy for the methods of this collection.

    Definition Classes
    Collection
    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.0) Internal: will be made private

Concrete Value Members

  1. object DeleteCommand extends DeleteCommand[pack.type]
    Definition Classes
    DeleteOps
  2. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  3. final def ##(): Int
    Definition Classes
    AnyRef → Any
  4. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toany2stringadd[GenericCollection[P]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  5. def ->[B](y: B): (GenericCollection[P], B)
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toArrowAssoc[GenericCollection[P]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  7. def MissingMetadata(): ConnectionNotInitialized
    Attributes
    protected
    Annotations
    @inline()
  8. def aggregateWith[T](explain: Boolean = false, allowDiskUse: Boolean = false, bypassDocumentValidation: Boolean = false, readConcern: Option[ReadConcern] = None, readPreference: ReadPreference = ReadPreference.primary, batchSize: Option[Int] = None)(f: (AggregationFramework) => (PipelineOperator, List[PipelineOperator]))(implicit reader: P.Reader[T], cp: CursorProducer[T]): ProducedCursor

    Aggregates the matching documents.

    Aggregates the matching documents.

    T

    The type of the result elements. An implicit Reader[T] typeclass for handling it has to be in the scope.

    explain

    if true indicates to return the information on the processing of the pipeline

    allowDiskUse

    if true enables writing to temporary files

    bypassDocumentValidation

    if true enables to bypass document validation during the operation

    readConcern

    the read concern

    readPreference

    the read preference for the result (default: primary)

    batchSize

    the batch size (for the aggregation cursor; if None use the default one)

    f

    the function to create the aggregation pipeline using the aggregation framework depending on the collection type

    reader

    the result reader

  9. def aggregatorContext[T](firstOperator: PipelineOperator, otherOperators: List[PipelineOperator] = Nil, explain: Boolean = false, allowDiskUse: Boolean = false, bypassDocumentValidation: Boolean = false, readConcern: Option[ReadConcern] = None, readPreference: ReadPreference = ReadPreference.primary, writeConcern: commands.WriteConcern = this.writeConcern, batchSize: Option[Int] = None, cursorOptions: CursorOptions = CursorOptions.empty, maxTimeMS: Option[Long] = None)(implicit reader: P.Reader[T]): AggregatorContext[T]

    Aggregates the matching documents.

    Aggregates the matching documents.

    import scala.concurrent.Future
    import scala.concurrent.ExecutionContext.Implicits.global
    
    import reactivemongo.bson._
    import reactivemongo.api.collections.bson.BSONCollection
    
    def populatedStates(cities: BSONCollection): Future[List[BSONDocument]] = {
      import cities.BatchCommands.AggregationFramework
      import AggregationFramework.{ Group, Match, SumField }
    
      cities.aggregatorContext[BSONDocument](Group(BSONString("$state"))(
        "totalPop" -> SumField("population")), List(
          Match(document("totalPop" ->
            document("$gte" -> 10000000L))))).
        prepared.cursor.collect[List]()
    }
    T

    The type of the result elements. An implicit Reader[T] typeclass for handling it has to be in the scope.

    firstOperator

    the first aggregation operator of the pipeline

    otherOperators

    the sequence of MongoDB aggregation operations

    explain

    if true indicates to return the information on the processing of the pipeline

    allowDiskUse

    if true enables writing to temporary files

    bypassDocumentValidation

    if true enables to bypass document validation during the operation

    readConcern

    the read concern

    readPreference

    the read preference for the result

    writeConcern

    the writer concern to be used

    batchSize

    the batch size (for the aggregation cursor; if None use the default one)

    cursorOptions

    the options for the result cursor

    maxTimeMS

    specifies a time limit in milliseconds for processing operations on a cursor.

    reader

    the result reader

  10. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  11. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  12. def convertToCapped(size: Long, maxDocuments: Option[Int])(implicit ec: ExecutionContext): Future[Unit]

    Converts this collection to a capped one.

    Converts this collection to a capped one.

    size

    the size of the collection (number of bytes)

    maxDocuments

    the maximum number of documents this capped collection can contain

    Definition Classes
    CollectionMetaCommands
  13. def count(selector: Option[P.Document], limit: Option[Int], skip: Int, hint: Option[Hint[pack.type]], readConcern: ReadConcern)(implicit ec: ExecutionContext): Future[Long]

    Counts the matching documents.

    Counts the matching documents.

    selector

    the document selector

    limit

    the maximum number of matching documents to count

    skip

    the number of matching documents to skip before counting

    hint

    the index to use (either the index name or the index document; see hint(..))

    readConcern

    the read concern

    See also

    MongoDB documentation

  14. def countDocuments(query: Option[P.Document], limit: Option[Int], skip: Int, hint: Option[Hint[pack.type]], readConcern: ReadConcern)(implicit ec: ExecutionContext): Future[Long]
    Attributes
    protected
    Definition Classes
    CountOp
  15. def create(failsIfExists: Boolean = false)(implicit ec: ExecutionContext): Future[Unit]

    failsIfExists

    if true fails if the collection already exists (default: false)

    Definition Classes
    CollectionMetaCommands
  16. def create()(implicit ec: ExecutionContext): Future[Unit]

    Creates this collection.

    Creates this collection.

    The returned future will be completed with an error if this collection already exists.

    coll.create().recover {
      case CommandError.Code(48 /*NamespaceExists*/ ) =>
        println(s"Collection ${coll.fullCollectionName} already exists")
    }
    Definition Classes
    CollectionMetaCommands
  17. def createCapped(size: Long, maxDocuments: Option[Int], autoIndexId: Boolean = false)(implicit ec: ExecutionContext): Future[Unit]

    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.

    size

    the size of the collection (number of bytes)

    maxDocuments

    the maximum number of documents this capped collection can contain

    autoIndexId

    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.

    Definition Classes
    CollectionMetaCommands
  18. def createView(name: String, operator: PipelineOperator, pipeline: Seq[PipelineOperator], collation: Option[Collation] = None)(implicit ec: ExecutionContext): Future[Unit]

    Creates a view on this collection, using an aggregation pipeline.

    Creates a view on this collection, using an aggregation pipeline.

    import coll.BatchCommands.AggregationFramework
    import AggregationFramework.{ Group, Match, SumField }
    
    // See http://docs.mongodb.org/manual/tutorial/aggregation-zip-code-data-set/#return-states-with-populations-above-10-million
    
    // Create 'myview'
    coll.createView(
      name = "myview",
      operator = Group(BSONString(f"$$state"))(
        "totalPop" -> SumField("population")),
    pipeline = Seq(
    Match(document("totalPop" -> document(f"$$gte" -> 10000000L)))))
    
    
    // Then the view can be resolved as any collection
    // (but won't be writeable)
    val view: BSONCollection = db("myview")
    name

    the name of the view to be created

    operator

    the first (required) operator for the aggregation pipeline

    pipeline

    the other pipeline operators

    collation

    the view collation

    Definition Classes
    GenericCollectionMetaCommands
    See also

    db.createView

  19. def defaultCursorBatchSize: Int
    Attributes
    protected
    Annotations
    @inline()
  20. def delete(ordered: Boolean = true, writeConcern: commands.WriteConcern = writeConcern): DeleteBuilder

    Prepares a delete builder.

    Prepares a delete builder.

    ordered

    the ordered behaviour

    writeConcern

    the writer concern to be used

    collection.delete(true, defaultWriteConcern).one(document, limit)
  21. def delete: DeleteBuilder

    Prepares an unordered delete builder.

    Prepares an unordered delete builder.

    collection.delete.one(document, limit)
    
    // Equivalent to .delete(false, defaultWriteConcern)
  22. def distinct[T, M[_] <: Iterable[_]](key: String, selector: Option[P.Document], readConcern: ReadConcern, collation: Option[Collation])(implicit reader: P.NarrowValueReader[T], ec: ExecutionContext, cbf: Factory[T, M[T]]): Future[M[T]]

    Returns the distinct values for a specified field across a single collection.

    Returns the distinct values for a specified field across a single collection.

    T

    the element type of the distinct values

    M

    the container, that must be a scala.collection.Iterable

    key

    the field for which to return distinct values

    selector

    the document selector, that specifies the documents from which to retrieve the distinct values.

    readConcern

    the read concern

    collation

    the collation

    val distinctStates = collection.distinct[String, Set](
      "state", None, ReadConcern.Local, None)
    Definition Classes
    GenericCollectionWithDistinctOps
  23. def distinctDocuments[T, M[_] <: Iterable[_]](key: String, query: Option[P.Document], readConcern: ReadConcern, collation: Option[Collation], builder: Builder[T, M[T]])(implicit reader: P.NarrowValueReader[T], ec: ExecutionContext): Future[M[T]]
    Attributes
    protected
    Definition Classes
    DistinctOp
  24. final def distinctDocuments[T, M[_] <: Iterable[_]](key: String, query: Option[P.Document], readConcern: ReadConcern, collation: Option[Collation])(implicit reader: P.NarrowValueReader[T], ec: ExecutionContext, cbf: Factory[T, M[T]]): Future[M[T]]
    Attributes
    protected
    Definition Classes
    DistinctOpCompat
  25. def drop(failIfNotFound: Boolean)(implicit ec: ExecutionContext): Future[Boolean]

    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.

    Definition Classes
    CollectionMetaCommands
  26. def ensuring(cond: (GenericCollection[P]) => Boolean, msg: => Any): GenericCollection[P]
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toEnsuring[GenericCollection[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  27. def ensuring(cond: (GenericCollection[P]) => Boolean): GenericCollection[P]
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toEnsuring[GenericCollection[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  28. def ensuring(cond: Boolean, msg: => Any): GenericCollection[P]
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toEnsuring[GenericCollection[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  29. def ensuring(cond: Boolean): GenericCollection[P]
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toEnsuring[GenericCollection[P]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  30. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  31. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  32. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  33. def find[S, J](selector: S, projection: Option[J] = Option.empty)(implicit swriter: P.Writer[S], pwriter: P.Writer[J]): GenericQueryBuilder[pack.type]

    Finds the documents matching the given criteria (selector), with the projection applied.

    Finds the documents matching the given criteria (selector), with the projection applied.

    S

    The type of the selector. An implicit Writer[S] typeclass for handling it has to be in the scope.

    selector

    the document selector

    projection

    the projection document to select only a subset of each matching documents

    swriter

    the writer for the selector

    pwriter

    the writer for the projection

    returns

    A GenericQueryBuilder that you can use to to customize the query. You can obtain a cursor by calling the method reactivemongo.api.Cursor on this query builder.

    See also

    MongoDB documentation

  34. def findAndModify[S](selector: S, modifier: Modify, sort: Option[P.Document], fields: Option[P.Document], bypassDocumentValidation: Boolean, writeConcern: commands.WriteConcern, maxTime: Option[FiniteDuration], collation: Option[Collation], arrayFilters: Seq[P.Document])(implicit swriter: P.Writer[S], ec: ExecutionContext): Future[Result[pack.type]]

    Applies a findAndModify operation.

    Applies a findAndModify operation. See findAndUpdate and findAndRemove convenient functions.

    val updateOp = collection.updateModifier(
      BSONDocument("$set" -> BSONDocument("age" -> 35)))
    
    val personBeforeUpdate: Future[Option[Person]] =
      collection.findAndModify(BSONDocument("name" -> "Joline"), updateOp).
      map(_.result[Person])
    
    val removedPerson: Future[Option[Person]] = collection.findAndModify(
      BSONDocument("name" -> "Jack"), collection.removeModifier).
      map(_.result[Person])
    selector

    the document selector

    modifier

    the modify operator to be applied

    sort

    the document indicating the sort criteria (default: None)

    fields

    the projection fields

    writeConcern

    the writer concern to be used

    collation

    the collation

    arrayFilters

    an array of filter documents that determines which array elements to modify for an update operation on an array field

    swriter

    the writer for the selector

  35. def findAndRemove[S](selector: S, sort: Option[P.Document], fields: Option[P.Document], writeConcern: commands.WriteConcern, maxTime: Option[FiniteDuration], collation: Option[Collation], arrayFilters: Seq[P.Document])(implicit swriter: P.Writer[S], ec: ExecutionContext): Future[Result[pack.type]]

    Finds some matching document, and removes it (using findAndModify).

    Finds some matching document, and removes it (using findAndModify).

    val removed: Future[Person] = collection.findAndRemove(
      BSONDocument("name" -> "Foo")).map(_.result[Person])
    S

    The type of the selector. An implicit Writer[S] typeclass for handling it has to be in the scope.

    selector

    the document selector

    sort

    the document indicating the sort criteria

    fields

    the projection fields

    writeConcern

    the writer concern to be used

    collation

    the collation

    arrayFilters

    an array of filter documents that determines which array elements to modify for an update operation on an array field

    swriter

    the writer for the selector

  36. def findAndUpdate[S, T](selector: S, update: T, fetchNewObject: Boolean, upsert: Boolean, sort: Option[P.Document], fields: Option[P.Document], bypassDocumentValidation: Boolean, writeConcern: commands.WriteConcern, maxTime: Option[FiniteDuration], collation: Option[Collation], arrayFilters: Seq[P.Document])(implicit swriter: P.Writer[S], writer: P.Writer[T], ec: ExecutionContext): Future[Result[pack.type]]

    Finds some matching document, and updates it (using findAndModify).

    Finds some matching document, and updates it (using findAndModify).

    val person: Future[BSONDocument] = collection.findAndUpdate(
      BSONDocument("name" -> "James"),
      BSONDocument("$set" -> BSONDocument("age" -> 17)),
      fetchNewObject = true) // on success, return the update document:
                             // { "age": 17 }
    selector

    the document selector

    update

    the update to be applied

    fetchNewObject

    the command result must be the new object instead of the old one.

    upsert

    if true, creates a new document if no document is matching, otherwise if at least one document matches, an update is applied

    sort

    the document indicating the sort criteria (default: None)

    fields

    the projection fields

    writeConcern

    the writer concern to be used

    collation

    the collation

    arrayFilters

    an array of filter documents that determines which array elements to modify for an update operation on an array field

    swriter

    the writer for the selector

    writer

    the writer to create the document

  37. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toStringFormat[GenericCollection[P]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  38. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  39. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  40. def hint(specification: P.Document): Hint[pack.type]

    Returns a hint for the given index specification document.

    Returns a hint for the given index specification document.

    specification

    the index specification document

    Definition Classes
    HintFactory
  41. def hint(name: String): Hint[pack.type]

    Returns a hint for the given index name.

    Returns a hint for the given index name.

    name

    the index name

    Definition Classes
    HintFactory
  42. def indexesManager(implicit ec: ExecutionContext): CollectionIndexesManager

    Returns an index manager for this collection.

    Returns an index manager for this collection.

    Definition Classes
    CollectionMetaCommands
  43. def insert(ordered: Boolean, writeConcern: commands.WriteConcern): InsertBuilder

    Returns a builder for insert operations.

    Returns a builder for insert operations.

    ordered

    the ordered behaviour

    writeConcern

    the writer concern to be used

    collection.insert(true, aWriteConcern).one(singleDoc)
    
    collection.insert(true, aWriteConcern).many(multiInserts)
  44. def insert(ordered: Boolean): InsertBuilder

    Returns a builder for insert operations.

    Returns a builder for insert operations. Uses the default write concern.

    ordered

    the ordered behaviour

    collection.insert(ordered = true).one(singleDoc)
    
    collection.insert(ordered = true).many(multiInserts)
  45. def insert: InsertBuilder

    Returns an unordered builder for insert operations.

    Returns an unordered builder for insert operations. Uses the default write concern.

  46. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  47. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  48. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  49. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  50. def readConcern: ReadConcern

    The default read concern

    The default read concern

    Attributes
    protected
    Annotations
    @inline()
  51. def readPreference: ReadPreference

    The default read preference

    The default read preference

    Annotations
    @inline()
  52. def runCommand[C <: CollectionCommand](command: C)(implicit writer: P.Writer[ResolvedCollectionCommand[C]]): CursorFetcher[pack.type, Cursor]
  53. def runCommand[R, C <: CollectionCommand with CommandWithResult[R]](command: C with CommandWithResult[R], readPreference: ReadPreference = self.readPreference)(implicit writer: P.Writer[ResolvedCollectionCommand[C]], reader: P.Reader[R], ec: ExecutionContext): Future[R]
  54. def runValueCommand[A <: AnyVal, R <: BoxedAnyVal[A], C <: CollectionCommand with CommandWithResult[R]](command: C with CommandWithResult[R with BoxedAnyVal[A]], rp: ReadPreference = self.readPreference)(implicit writer: P.Writer[ResolvedCollectionCommand[C]], reader: P.Reader[R], ec: ExecutionContext): Future[A]
  55. def runWithResponse[R, C <: CollectionCommand with CommandWithResult[R]](command: C with CommandWithResult[R], readPreference: ReadPreference = self.readPreference)(implicit writer: P.Writer[ResolvedCollectionCommand[C]], reader: P.Reader[R], ec: ExecutionContext): Future[ResponseResult[R]]
  56. def runner: CommandWithPackRunner[pack.type]
  57. def sibling[C <: Collection](name: String, failoverStrategy: FailoverStrategy = failoverStrategy)(implicit producer: CollectionProducer[C] = BSONCollectionProducer): C

    Gets another collection in the current database.

    Gets another collection in the current database. An implicit CollectionProducer[C] must be present in the scope, or it will be the default implementation (reactivemongo.api.collections.bson.BSONCollection).

    name

    the name of another collection

    failoverStrategy

    the failover strategy to override the default one

    Definition Classes
    Collection
  58. def stats(scale: Int)(implicit ec: ExecutionContext): Future[CollStatsResult]

    Returns various information about this collection.

    Returns various information about this collection.

    scale

    the scale factor (for example, to get all the sizes in kilobytes)

    Definition Classes
    CollectionMetaCommands
  59. def stats()(implicit ec: ExecutionContext): Future[CollStatsResult]

    Returns various information about this collection.

    Returns various information about this collection.

    Definition Classes
    CollectionMetaCommands
  60. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  61. def toString(): String
    Definition Classes
    AnyRef → Any
  62. implicit lazy val unitBoxReader: P.Reader[UnitBox.type]
    Attributes
    protected
  63. def update(ordered: Boolean, writeConcern: commands.WriteConcern): UpdateBuilder

    Returns an update builder.

    Returns an update builder.

    collection.update(ordered, writeConcern).many(updates)
  64. def update(ordered: Boolean): UpdateBuilder

    Returns an update builder.

    Returns an update builder.

    collection.update(ordered = true).
      one(query, update, upsert = false, multi = false)
  65. def update: UpdateBuilder

    Returns an unordered update builder.

    Returns an unordered update builder.

    collection.update.one(query, update, upsert = false, multi = false)
  66. def updateModifier[U](update: U, fetchNewObject: Boolean = false, upsert: Boolean = false)(implicit updateWriter: P.Writer[U]): Update

    Returns an update modifier, to be used with findAndModify.

    Returns an update modifier, to be used with findAndModify.

    update

    the update to be applied

    fetchNewObject

    the command result must be the new object instead of the old one.

    upsert

    if true, creates a new document if no document is matching, otherwise if at least one document matches, an update is applied

  67. lazy val version: MongoWireVersion

    Upper MongoDB version (used for version checks)

    Upper MongoDB version (used for version checks)

    Attributes
    protected
  68. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  69. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  70. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  71. final def watch[T](resumeAfter: Option[P.Value] = None, startAtOperationTime: Option[P.Value] = None, pipeline: List[PipelineOperator] = Nil, maxAwaitTimeMS: Option[Long] = None, fullDocumentStrategy: Option[FullDocumentStrategy] = None)(implicit reader: P.Reader[T]): WatchBuilder[T]

    Prepares a builder for watching the changeStream of this collection https://docs.mongodb.com/manual/changeStreams (since MongoDB 3.6).

    Prepares a builder for watching the changeStream of this collection https://docs.mongodb.com/manual/changeStreams (since MongoDB 3.6).

    Note: the target mongo instance MUST be a replica-set (even in the case of a single node deployement).

    T

    the type into which Change Events are deserialized

    resumeAfter

    The id of the last known Change Event, if any. The stream will resume just after that event.

    startAtOperationTime

    The operation time before which all Change Events are known. Must be in the time range of the oplog. (since MongoDB 4.0)

    pipeline

    A sequence of aggregation stages to apply on events in the stream (see MongoDB documentation for a list of valid stages for a change stream).

    maxAwaitTimeMS

    The maximum amount of time in milliseconds the server waits for new data changes before returning an empty batch. In practice, this parameter controls the duration of the long-polling behavior of the cursor.

    fullDocumentStrategy

    if set to UpdateLookup, every update change event will be joined with the *current* version of the relevant document.

    reader

    a reader of the resulting Change Events

    Definition Classes
    ChangeStreamOps
  72. def watchFailure[T](future: => Future[T]): Future[T]
    Attributes
    protected
  73. def writeConcern: commands.WriteConcern

    The default write concern

    The default write concern

    Attributes
    protected
    Annotations
    @inline()
  74. def writePreference: ReadPreference

    The read preference for the write operations (primary)

    The read preference for the write operations (primary)

    Attributes
    protected
    Annotations
    @inline()
  75. object UpdateCommand extends UpdateCommand[pack.type]
    Definition Classes
    UpdateOps
  76. object ImplicitlyDocumentProducer
    Definition Classes
    ImplicitCommandHelpers

Deprecated Value Members

  1. implicit def PackIdentityReader: P.Reader[P.Document]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.0) Internal: will be made private

  2. implicit def PackIdentityWriter: P.Writer[P.Document]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.0) Internal: will be made private

  3. def aggregateWith1[T](explain: Boolean = false, allowDiskUse: Boolean = false, bypassDocumentValidation: Boolean = false, readConcern: Option[ReadConcern] = None, readPreference: ReadPreference = ReadPreference.primary, batchSize: Option[Int] = None)(f: (AggregationFramework) => (PipelineOperator, List[PipelineOperator]))(implicit ec: ExecutionContext, reader: P.Reader[T], cf: CursorFlattener[Cursor], cp: CursorProducer[T]): ProducedCursor

    Aggregates the matching documents.

    Aggregates the matching documents.

    T

    The type of the result elements. An implicit Reader[T] typeclass for handling it has to be in the scope.

    explain

    if true indicates to return the information on the processing of the pipeline

    allowDiskUse

    if true enables writing to temporary files

    bypassDocumentValidation

    if true enables to bypass document validation during the operation

    readConcern

    the read concern

    readPreference

    the read preference for the result (default: primary)

    batchSize

    the batch size (for the aggregation cursor; if None use the default one)

    f

    the function to create the aggregation pipeline using the aggregation framework depending on the collection type

    reader

    the result reader

    cf

    the cursor flattener (by default use the builtin one)

    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.0) Use aggregateWith

  4. def aggregatorContext[T](firstOperator: PipelineOperator, otherOperators: List[PipelineOperator], explain: Boolean, allowDiskUse: Boolean, bypassDocumentValidation: Boolean, readConcern: Option[ReadConcern], readPreference: ReadPreference, batchSize: Option[Int])(implicit reader: P.Reader[T]): AggregatorContext[T]
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 0.17.0) Use aggregator context with optional writeConcern

  5. def as[C <: Collection](failoverStrategy: FailoverStrategy = failoverStrategy)(implicit producer: CollectionProducer[C] = BSONCollectionProducer): C

    Gets another implementation of this collection.

    Gets another implementation of this collection. An implicit CollectionProducer[C] must be present in the scope, or it will be the default implementation (reactivemongo.api.collections.bson.BSONCollection).

    failoverStrategy

    the failover strategy to override the default one

    Definition Classes
    Collection
    Annotations
    @deprecated
    Deprecated

    (Since version 0.13.0) Resolve the collection from DB

  6. def count[H](selector: Option[P.Document] = None, limit: Int = 0, skip: Int = 0, hint: Option[H] = None)(implicit h: (H) => commands.CountCommand.Hint, ec: ExecutionContext): Future[Int]

    Counts the matching documents.

    Counts the matching documents.

    H

    The type of hint. An implicit H => Hint conversion has to be in the scope.

    selector

    the document selector (default: None to count all)

    limit

    the maximum number of matching documents to count

    skip

    the number of matching documents to skip before counting

    hint

    the index to use (either the index name or the index document)

    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.0) Use count with readConcern parameter

    See also

    MongoDB documentation

  7. def drop()(implicit ec: ExecutionContext): Future[Unit]

    Drops this collection.

    Drops this collection.

    The returned future will be completed with an error if this collection does not exist.

    Definition Classes
    CollectionMetaCommands
    Annotations
    @deprecated
    Deprecated

    (Since version 0.12.0) Use drop(Boolean)

  8. def find[S, J](selector: S, projection: J)(implicit swriter: P.Writer[S], pwriter: P.Writer[J]): GenericQueryBuilder[pack.type]

    Finds the documents matching the given criteria (selector), with the projection applied.

    Finds the documents matching the given criteria (selector), with the projection applied.

    S

    The type of the selector. An implicit Writer[S] typeclass for handling it has to be in the scope.

    selector

    the document selector

    projection

    the projection document to select only a subset of each matching documents

    swriter

    the writer for the selector

    pwriter

    the writer for the projection

    returns

    A GenericQueryBuilder that you can use to to customize the query. You can obtain a cursor by calling the method reactivemongo.api.Cursor on this query builder.

    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.0) Use find with optional projection

    See also

    MongoDB documentation

  9. def find[S](selector: S)(implicit swriter: P.Writer[S]): GenericQueryBuilder[pack.type]

    Finds the documents matching the given criteria (selector).

    Finds the documents matching the given criteria (selector).

    S

    The type of the selector. An implicit Writer[S] typeclass for handling it has to be in the scope.

    selector

    the document selector

    swriter

    the writer for the selector

    returns

    A GenericQueryBuilder that you can use to to customize the query. You can obtain a cursor by calling the method reactivemongo.api.Cursor on this query builder.

    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.0) Use find with optional projection

    See also

    MongoDB documentation

  10. def findAndModify[S](selector: S, modifier: Modify, sort: Option[P.Document] = None, fields: Option[P.Document] = None)(implicit swriter: P.Writer[S], ec: ExecutionContext): Future[FindAndModifyResult]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.14.0) Use other findAndModify

  11. def findAndRemove[S](selector: S, sort: Option[P.Document] = None, fields: Option[P.Document] = None)(implicit swriter: P.Writer[S], ec: ExecutionContext): Future[FindAndModifyResult]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.18.0) Use the other findAndRemove

  12. def findAndUpdate[S, T](selector: S, update: T, fetchNewObject: Boolean = false, upsert: Boolean = false, sort: Option[P.Document] = None, fields: Option[P.Document] = None)(implicit swriter: P.Writer[S], writer: P.Writer[T], ec: ExecutionContext): Future[FindAndModifyResult]
    Annotations
    @deprecated
    Deprecated

    (Since version 0.18.0) Use other findAndUpdate

  13. final def fullCollectionName: String

    Gets the full qualified name of this collection.

    Gets the full qualified name of this collection.

    Definition Classes
    Collection
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 0.17.0) Internal: will be made private

  14. def insert[T](document: T, writeConcern: commands.WriteConcern = writeConcern)(implicit writer: P.Writer[T], ec: ExecutionContext): Future[WriteResult]

    Inserts a document into the collection and waits for the reactivemongo.api.commands.WriteResult.

    Inserts a document into the collection and waits for the reactivemongo.api.commands.WriteResult.

    T

    The type of the document to insert. An implicit Writer[T] typeclass for handling it has to be in the scope.

    document

    the document to insert

    writeConcern

    the writer concern to be used

    writer

    the writer to create the document to be inserted

    returns

    a future reactivemongo.api.commands.WriteResult that can be used to check whether the insertion was successful

    collection.insert(myDoc)
    
    // Equivalent to:
    collection.insert(true, defaultWriteConcern).one(document)
    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.1) Use .insert(ordered = false).one(..)

  15. def remove[S](selector: S, writeConcern: commands.WriteConcern = writeConcern, firstMatchOnly: Boolean = false)(implicit swriter: P.Writer[S], ec: ExecutionContext): Future[WriteResult]

    S

    The type of the selector. An implicit Writer[S] typeclass for handling it has to be in the scope.

    writeConcern

    the writer concern to be used

    swriter

    the writer for the selector

    returns

    a future reactivemongo.api.commands.WriteResult that can be used to check whether the removal was successful

    // Equivalent to:
    collection.delete(true, defaultWriteConcern).one(document, limit)
    Annotations
    @deprecated
    Deprecated

    (Since version 0.13.1) Use delete().one(selector, limit)

  16. lazy val removeModifier: Remove

    Returns a removal modifier, to be used with findAndModify.

    Returns a removal modifier, to be used with findAndModify.

    Annotations
    @deprecated @transient()
    Deprecated

    (Since version 0.16.0) Internal: will be made private

  17. def rename(to: String, dropExisting: Boolean = false)(implicit ec: ExecutionContext): Future[Unit]

    Renames this collection.

    Renames this collection.

    to

    the new name of this collection

    dropExisting

    if a collection of name to already exists, then drops that collection before renaming this one

    returns

    a failure if the dropExisting option is false and the target collection already exists

    Definition Classes
    CollectionMetaCommands
    Annotations
    @deprecated
    Deprecated

    (Since version 0.12.4) Use reactivemongo.api.DBMetaCommands.renameCollection on the admin database instead.

  18. def update[S, T](selector: S, update: T, writeConcern: commands.WriteConcern = writeConcern, upsert: Boolean = false, multi: Boolean = false)(implicit swriter: P.Writer[S], writer: P.Writer[T], ec: ExecutionContext): Future[UpdateWriteResult]

    Updates one or more documents matching the given selector with the given modifier or update object.

    Updates one or more documents matching the given selector with the given modifier or update object.

    S

    The type of the selector. An implicit Writer[S] typeclass for handling it has to be in the scope.

    T

    The type of the modifier or update object. An implicit Writer[T] typeclass for handling it has to be in the scope.

    selector

    the selector object, for finding the documents to update.

    update

    the modifier object (with special keys like $set) or replacement object.

    writeConcern

    the writer concern to be used

    upsert

    if true, creates a new document if no document is matching, otherwise if at least one document matches, an update is applied (defaults: false)

    multi

    states whether the update may be done on all the matching documents (default: false)

    swriter

    the writer for the selector

    writer

    the writer to create the document

    returns

    a future reactivemongo.api.commands.WriteResult that can be used to check whether the insertion was successful

    Annotations
    @deprecated
    Deprecated

    (Since version 0.16.1) Use .update(ordered = false).one(..)

  19. def [B](y: B): (GenericCollection[P], B)
    Implicit
    This member is added by an implicit conversion from GenericCollection[P] toArrowAssoc[GenericCollection[P]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from HintFactory[P]

Inherited from GenericCollectionWithQueryBuilder[P]

Inherited from GenericCollectionMetaCommands[P]

Inherited from collections.Aggregator[P]

Inherited from ChangeStreamOps[P]

Inherited from FindAndModifyOps[P]

Inherited from GenericCollectionWithDistinctOps[P]

Inherited from DistinctOp[P]

Inherited from DistinctOpCompat[P]

Inherited from CountOp[P]

Inherited from DeleteOps[P]

Inherited from UpdateOps[P]

Inherited from InsertOps[P]

Inherited from ImplicitCommandHelpers[P]

Inherited from CollectionMetaCommands

Inherited from Collection

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromGenericCollection[P] to any2stringadd[GenericCollection[P]]

Inherited by implicit conversion StringFormat fromGenericCollection[P] to StringFormat[GenericCollection[P]]

Inherited by implicit conversion Ensuring fromGenericCollection[P] to Ensuring[GenericCollection[P]]

Inherited by implicit conversion ArrowAssoc fromGenericCollection[P] to ArrowAssoc[GenericCollection[P]]

Ungrouped