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.collect[List]()
  futureList.map { list =>
    list.foreach { doc =>
      println("found document: " + BSONDocument.pretty(doc))
    }
  }
}
}
Linear Supertypes
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 StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  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: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

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

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

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

    Definition Classes
    AnyRef → Any
  6. def BufferReaderInstance[T](reader: BSONDocumentReader[T]): GenericBufferReader[T]

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

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

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

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

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

    Definition Classes
    BSONGenericHandlersGenericHandlers
  12. 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
  13. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  14. def bulkInsert[T](enumerator: Enumerator[T], writeConcern: GetLastError = GetLastError(), bulkSize: Int = bulk.MaxDocs, bulkByteSize: Int = bulk.MaxBulkSize)(implicit writer: BSONDocumentWriter[T], ec: ExecutionContext): Future[Int]

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

    Definition Classes
    GenericCollection
  16. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  17. 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
  18. 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
  19. 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
  20. val db: DB

    The database which this collection belong to.

    The database which this collection belong to.

    Definition Classes
    BSONCollectionCollection
  21. 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
  22. 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 Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  23. def ensuring(cond: (BSONCollection) ⇒ Boolean): BSONCollection

    Implicit information
    This member is added by an implicit conversion from BSONCollection to Ensuring[BSONCollection] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  24. 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 Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  25. def ensuring(cond: Boolean): BSONCollection

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

    Definition Classes
    AnyRef
  27. 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
  28. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  29. 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
  30. 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
  31. def formatted(fmtstr: String): String

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

    Gets the full qualified name of this collection.

    Gets the full qualified name of this collection.

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

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

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

    Returns an index manager for this collection.

    Returns an index manager for this collection.

    Definition Classes
    CollectionMetaCommands
  36. 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
  37. 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
  38. def insert[T](document: T, writeConcern: GetLastError = 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
  39. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  40. val name: String

    The name of the collection.

    The name of the collection.

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

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

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

    Definition Classes
    AnyRef
  44. def remove[T](query: T, writeConcern: GetLastError = GetLastError(), firstMatchOnly: Boolean = false)(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
  45. 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
  46. def save[T](doc: T, writeConcern: GetLastError = 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().

  47. 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().

  48. 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.

  49. def sibling[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
  50. 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
  51. def stats()(implicit ec: ExecutionContext): Future[CollStatsResult]

    Returns various information about this collection.

    Returns various information about this collection.

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

    Definition Classes
    AnyRef
  53. 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
  54. def uncheckedRemove[T](query: T, firstMatchOnly: Boolean = false)(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
  55. def uncheckedUpdate[S, U](selector: S, update: U, upsert: Boolean = false, multi: Boolean = false)(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
  56. def update[S, U](selector: S, update: U, writeConcern: GetLastError = GetLastError(), upsert: Boolean = false, multi: Boolean = false)(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
  57. final def wait(): Unit

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

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

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

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

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

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 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
    Annotations
    @deprecated
    Deprecated

    (Since version 0.10) Consider using sibling instead

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from CollectionMetaCommands

Inherited from BSONGenericHandlers

Inherited from Collection

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from BSONCollection to any2stringadd[BSONCollection]

Inherited by implicit conversion StringFormat from BSONCollection to StringFormat[BSONCollection]

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

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

Ungrouped