reactivemongo.api.collections.default

BSONCollection

case class BSONCollection(db: DB, name: String, failoverStrategy: FailoverStrategy) extends GenericCollection[BSONDocument, BSONDocumentReader, BSONDocumentWriter] with BSONGenericHandlers with CollectionMetaCommands with Product with Serializable

The default implementation of Collection.

object Samples {

val connection = MongoConnection(List("localhost"))

// Gets a reference to the database "plugin"
val db = connection("plugin")

// Gets a reference to the collection "acoll"
// By default, you get a BSONCollection.
val collection = db("acoll")

def listDocs() = {
  // Select only the documents which field 'firstName' equals 'Jack'
  val query = BSONDocument("firstName" -> "Jack")
  // select only the field 'lastName'
  val filter = BSONDocument(
    "lastName" -> 1,
    "_id" -> 0)

  // Get a cursor of BSONDocuments
  val cursor = collection.find(query, filter).cursor[BSONDocument]
  // Let's enumerate this cursor and print a readable representation of each document in the response
  cursor.enumerate.apply(Iteratee.foreach { doc =>
    println("found document: " + BSONDocument.pretty(doc))
  })

  // Or, the same with getting a list
  val cursor2 = collection.find(query, filter).cursor[BSONDocument]
  val futureList = cursor.toList
  futureList.map { list =>
    list.foreach { doc =>
      println("found document: " + BSONDocument.pretty(doc))
    }
  }
}
}
Linear Supertypes
Serializable, Serializable, Product, Equals, CollectionMetaCommands, BSONGenericHandlers, GenericCollection[BSONDocument, BSONDocumentReader, BSONDocumentWriter], GenericHandlers[BSONDocument, BSONDocumentReader, BSONDocumentWriter], Collection, AnyRef, Any
Type Hierarchy Learn more about scaladoc diagrams
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. BSONCollection
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. CollectionMetaCommands
  7. BSONGenericHandlers
  8. GenericCollection
  9. GenericHandlers
  10. Collection
  11. AnyRef
  12. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BSONCollection(db: DB, name: String, failoverStrategy: FailoverStrategy)

Type Members

  1. case class BSONStructureReader[T](reader: BSONDocumentReader[T]) extends GenericReader[BSONDocument, T] with Product with Serializable

    Definition Classes
    BSONGenericHandlers
  2. case class BSONStructureWriter[T](writer: BSONDocumentWriter[T]) extends GenericWriter[T, BSONDocument] with Product with Serializable

    Definition Classes
    BSONGenericHandlers
  3. case class GenericBufferReader[T](reader: Reader[T]) extends BufferReader[T] with Product with Serializable

    Definition Classes
    GenericHandlers
  4. case class GenericBufferWriter[T](writer: Writer[T]) extends BufferWriter[T] with Product with Serializable

    Definition Classes
    GenericHandlers

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from BSONCollection to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (BSONCollection, B)

    Implicit information
    This member is added by an implicit conversion from BSONCollection to ArrowAssoc[BSONCollection] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. def BufferReaderInstance[T](reader: BSONDocumentReader[T]): GenericBufferReader[T]

    Definition Classes
    GenericHandlers
  9. def BufferWriterInstance[T](writer: BSONDocumentWriter[T]): GenericBufferWriter[T]

    Definition Classes
    GenericHandlers
  10. object StructureBufferReader extends BufferReader[BSONDocument]

    Definition Classes
    BSONGenericHandlersGenericHandlers
  11. object StructureBufferWriter extends BufferWriter[BSONDocument]

    Definition Classes
    BSONGenericHandlersGenericHandlers
  12. def StructureReader[T](reader: BSONDocumentReader[T]): BSONStructureReader[T]

    Definition Classes
    BSONGenericHandlersGenericHandlers
  13. def StructureWriter[T](writer: BSONDocumentWriter[T]): GenericWriter[T, BSONDocument]

    Definition Classes
    BSONGenericHandlersGenericHandlers
  14. def as[C <: Collection](failoverStrategy: FailoverStrategy = failoverStrategy)(implicit producer: CollectionProducer[C]): 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.default.BSONCollection).

    failoverStrategy

    Overrides the default strategy.

    Definition Classes
    Collection
  15. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  16. def bulkInsert[T](enumerator: Enumerator[T], bulkSize: Int, bulkByteSize: Int)(implicit writer: BSONDocumentWriter[T], ec: ExecutionContext): Future[Int]

    Definition Classes
    GenericCollection
  17. def bulkInsertIteratee[T](bulkSize: Int = bulk.MaxDocs, bulkByteSize: Int = bulk.MaxBulkSize)(implicit writer: BSONDocumentWriter[T], ec: ExecutionContext): Iteratee[T, Int]

    Definition Classes
    GenericCollection
  18. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  19. def convertToCapped(size: Long, maxDocuments: Option[Int])(implicit ec: ExecutionContext): Future[Boolean]

    Converts this collection to a capped one.

    Converts this collection to a capped one.

    size

    The size of this capped collection, in bytes.

    maxDocuments

    The maximum number of documents this capped collection can contain.

    Definition Classes
    CollectionMetaCommands
  20. def create(autoIndexId: Boolean = true)(implicit ec: ExecutionContext): Future[Boolean]

    Creates this collection.

    Creates this collection.

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

    autoIndexId

    States if should automatically add an index on the _id field. By default, regular collections will have an indexed _id field, in contrast to capped collections.

    Definition Classes
    CollectionMetaCommands
  21. def createCapped(size: Long, maxDocuments: Option[Int], autoIndexId: Boolean = false)(implicit ec: ExecutionContext): Future[Boolean]

    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.

    autoIndexId

    States if should automatically add an index on the _id field. By default, capped collections will NOT have an indexed _id field, in contrast to regular collections.

    Definition Classes
    CollectionMetaCommands
  22. val db: DB

    The database which this collection belong to.

    The database which this collection belong to.

    Definition Classes
    BSONCollectionCollection
  23. def drop()(implicit ec: ExecutionContext): Future[Boolean]

    Drops this collection.

    Drops this collection.

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

    Definition Classes
    CollectionMetaCommands
  24. def ensuring(cond: (BSONCollection) ⇒ Boolean, msg: ⇒ Any): BSONCollection

    Implicit information
    This member is added by an implicit conversion from BSONCollection to Ensuring[BSONCollection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  25. def ensuring(cond: (BSONCollection) ⇒ Boolean): BSONCollection

    Implicit information
    This member is added by an implicit conversion from BSONCollection to Ensuring[BSONCollection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  26. def ensuring(cond: Boolean, msg: ⇒ Any): BSONCollection

    Implicit information
    This member is added by an implicit conversion from BSONCollection to Ensuring[BSONCollection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  27. def ensuring(cond: Boolean): BSONCollection

    Implicit information
    This member is added by an implicit conversion from BSONCollection to Ensuring[BSONCollection] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  28. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  29. val failoverStrategy: FailoverStrategy

    The default failover strategy for the methods of this collection.

    The default failover strategy for the methods of this collection.

    Definition Classes
    BSONCollectionGenericCollectionCollection
  30. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  31. def find[S, P](selector: S, projection: P)(implicit swriter: BSONDocumentWriter[S], pwriter: BSONDocumentWriter[P]): GenericQueryBuilder[BSONDocument, BSONDocumentReader, BSONDocumentWriter]

    Find the documents matching the given criteria.

    Find the documents matching the given criteria.

    This method accepts any query and projection object, provided that there is an implicit Writer[S] typeclass for handling them in the scope.

    Please take a look to the mongodb documentation to know how querying works.

    S

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

    P

    the type of the projection object. An implicit Writer[P] typeclass for handling it has to be in the scope.

    projection

    Get only a subset of each matched documents. Defaults to None.

    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.

    Definition Classes
    GenericCollection
  32. def find[S](selector: S)(implicit swriter: BSONDocumentWriter[S]): GenericQueryBuilder[BSONDocument, BSONDocumentReader, BSONDocumentWriter]

    Find the documents matching the given criteria.

    Find the documents matching the given criteria.

    This method accepts any query and projection object, provided that there is an implicit Writer[S] typeclass for handling them in the scope.

    Please take a look to the mongodb documentation to know how querying works.

    S

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

    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.

    Definition Classes
    GenericCollection
  33. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from BSONCollection to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  34. def fullCollectionName: String

    Gets the full qualified name of this collection.

    Gets the full qualified name of this collection.

    Definition Classes
    Collection
  35. def genericQueryBuilder: GenericQueryBuilder[BSONDocument, BSONDocumentReader, BSONDocumentWriter]

    Definition Classes
    BSONCollectionGenericCollection
  36. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  37. def indexesManager(implicit ec: ExecutionContext): CollectionIndexesManager

    Returns an index manager for this collection.

    Returns an index manager for this collection.

    Definition Classes
    CollectionMetaCommands
  38. def insert(document: BSONDocument)(implicit ec: ExecutionContext): Future[LastError]

    Inserts a document into the collection and wait for the reactivemongo.core.commands.LastError result.

    Inserts a document into the collection and wait for the reactivemongo.core.commands.LastError result.

    document

    the document to insert.

    returns

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

    Definition Classes
    GenericCollection
  39. def insert(document: BSONDocument, writeConcern: GetLastError)(implicit ec: ExecutionContext): Future[LastError]

    Inserts a document into the collection and wait for the reactivemongo.core.commands.LastError result.

    Inserts a document into the collection and wait for the reactivemongo.core.commands.LastError result.

    Please read the documentation about reactivemongo.core.commands.GetLastError to know how to use it properly.

    document

    the document to insert.

    writeConcern

    the reactivemongo.core.commands.GetLastError command message to send in order to control how the document is inserted. Defaults to GetLastError().

    returns

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

    Definition Classes
    GenericCollection
  40. def insert[T](document: T, writeConcern: GetLastError)(implicit writer: BSONDocumentWriter[T], ec: ExecutionContext): Future[LastError]

    Inserts a document into the collection and wait for the reactivemongo.core.commands.LastError result.

    Inserts a document into the collection and wait for the reactivemongo.core.commands.LastError result.

    Please read the documentation about reactivemongo.core.commands.GetLastError to know how to use it properly.

    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 reactivemongo.core.commands.GetLastError command message to send in order to control how the document is inserted. Defaults to GetLastError().

    returns

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

    Definition Classes
    GenericCollection
  41. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  42. val name: String

    The name of the collection.

    The name of the collection.

    Definition Classes
    BSONCollectionCollection
  43. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  44. final def notify(): Unit

    Definition Classes
    AnyRef
  45. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  46. def remove[T](query: T, writeConcern: GetLastError, firstMatchOnly: Boolean)(implicit writer: BSONDocumentWriter[T], ec: ExecutionContext): Future[LastError]

    Remove the matched document(s) from the collection and wait for the reactivemongo.core.commands.LastError result.

    Remove the matched document(s) from the collection and wait for the reactivemongo.core.commands.LastError result.

    Please read the documentation about reactivemongo.core.commands.GetLastError to know how to use it properly.

    T

    the type of the selector of documents to remove. An implicit Writer[T] typeclass for handling it has to be in the scope.

    query

    the selector of documents to remove.

    writeConcern

    the reactivemongo.core.commands.GetLastError command message to send in order to control how the documents are removed. Defaults to GetLastError().

    firstMatchOnly

    states whether only the first matched documents has to be removed from this collection.

    returns

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

    Definition Classes
    GenericCollection
  47. def rename(to: String, dropExisting: Boolean = false)(implicit ec: ExecutionContext): Future[Boolean]

    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.

    Definition Classes
    CollectionMetaCommands
  48. def save[T](doc: T, writeConcern: GetLastError)(implicit ec: ExecutionContext, writer: BSONDocumentWriter[T]): Future[LastError]

    Inserts the document, or updates it if it already exists in the collection.

    Inserts the document, or updates it if it already exists in the collection.

    doc

    The document to save.

    writeConcern

    the reactivemongo.core.commands.GetLastError command message to send in order to control how the document is inserted. Defaults to GetLastError().

  49. def save(doc: BSONDocument, writeConcern: GetLastError)(implicit ec: ExecutionContext): Future[LastError]

    Inserts the document, or updates it if it already exists in the collection.

    Inserts the document, or updates it if it already exists in the collection.

    doc

    The document to save.

    writeConcern

    the reactivemongo.core.commands.GetLastError command message to send in order to control how the document is inserted. Defaults to GetLastError().

  50. def save(doc: BSONDocument)(implicit ec: ExecutionContext): Future[LastError]

    Inserts the document, or updates it if it already exists in the collection.

    Inserts the document, or updates it if it already exists in the collection.

    doc

    The document to save.

  51. def sister[C <: Collection](name: String, failoverStrategy: FailoverStrategy = failoverStrategy)(implicit producer: CollectionProducer[C]): 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.default.BSONCollection).

    name

    The other collection name.

    failoverStrategy

    Overrides the default strategy.

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

    Returns various information about this collection.

    Returns various information about this collection.

    scale

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

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

    Returns various information about this collection.

    Returns various information about this collection.

    Definition Classes
    CollectionMetaCommands
  54. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  55. def uncheckedInsert[T](document: T)(implicit writer: BSONDocumentWriter[T]): Unit

    Inserts a document into the collection without writeConcern.

    Inserts a document into the collection without writeConcern.

    Please note that you cannot be sure that the document has been effectively written and when (hence the Unit return type).

    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.

    Definition Classes
    GenericCollection
  56. def uncheckedRemove[T](query: T, firstMatchOnly: Boolean)(implicit writer: BSONDocumentWriter[T], ec: ExecutionContext): Unit

    Remove the matched document(s) from the collection without writeConcern.

    Remove the matched document(s) from the collection without writeConcern.

    Please note that you cannot be sure that the matched documents have been effectively removed and when (hence the Unit return type).

    T

    the type of the selector of documents to remove. An implicit Writer[T] typeclass for handling it has to be in the scope.

    query

    the selector of documents to remove.

    firstMatchOnly

    states whether only the first matched documents has to be removed from this collection.

    Definition Classes
    GenericCollection
  57. def uncheckedUpdate[S, U](selector: S, update: U, upsert: Boolean, multi: Boolean)(implicit selectorWriter: BSONDocumentWriter[S], updateWriter: BSONDocumentWriter[U]): Unit

    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.

    Please note that you cannot be sure that the matched documents have been effectively updated and when (hence the Unit return type).

    S

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

    U

    the type of the modifier or update object. An implicit Writer[U] 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.

    upsert

    states whether the update objet should be inserted if no match found. Defaults to false.

    multi

    states whether the update may be done on all the matching documents.

    Definition Classes
    GenericCollection
  58. def update[S, U](selector: S, update: U, writeConcern: GetLastError, upsert: Boolean, multi: Boolean)(implicit selectorWriter: BSONDocumentWriter[S], updateWriter: BSONDocumentWriter[U], ec: ExecutionContext): Future[LastError]

    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 object. An implicit Writer[S] typeclass for handling it has to be in the scope.

    U

    the type of the modifier or update object. An implicit Writer[U] 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 reactivemongo.core.commands.GetLastError command message to send in order to control how the documents are updated. Defaults to GetLastError().

    upsert

    states whether the update objet should be inserted if no match found. Defaults to false.

    multi

    states whether the update may be done on all the matching documents.

    returns

    a future reactivemongo.core.commands.LastError that can be used to check whether the update was successful.

    Definition Classes
    GenericCollection
  59. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  60. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  61. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  62. def watchFailure[T](future: ⇒ Future[T]): Future[T]

    Attributes
    protected
    Definition Classes
    GenericCollection
  63. def [B](y: B): (BSONCollection, B)

    Implicit information
    This member is added by an implicit conversion from BSONCollection to ArrowAssoc[BSONCollection] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implict Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from BSONCollection to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (bSONCollection: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from BSONCollection to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (bSONCollection: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def emptyCapped()(implicit ec: ExecutionContext): Future[Boolean]

    If this collection is capped, removes all the documents it contains.

    If this collection is capped, removes all the documents it contains.

    Deprecated because it became an internal command, unavailable by default.

    Definition Classes
    CollectionMetaCommands
    Annotations
    @deprecated
    Deprecated

    (Since version 0.9) Deprecated because emptyCapped became an internal command, unavailable by default.

  2. def x: BSONCollection

    Implicit information
    This member is added by an implicit conversion from BSONCollection to ArrowAssoc[BSONCollection] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (bSONCollection: ArrowAssoc[BSONCollection]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  3. def x: BSONCollection

    Implicit information
    This member is added by an implicit conversion from BSONCollection to Ensuring[BSONCollection] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (bSONCollection: Ensuring[BSONCollection]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from CollectionMetaCommands

Inherited from BSONGenericHandlers

Inherited from GenericCollection[BSONDocument, BSONDocumentReader, BSONDocumentWriter]

Inherited from GenericHandlers[BSONDocument, BSONDocumentReader, BSONDocumentWriter]

Inherited from Collection

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from BSONCollection to StringAdd

Inherited by implicit conversion any2stringfmt from BSONCollection to StringFormat

Inherited by implicit conversion any2ArrowAssoc from BSONCollection to ArrowAssoc[BSONCollection]

Inherited by implicit conversion any2Ensuring from BSONCollection to Ensuring[BSONCollection]

Ungrouped