reactivemongo.extensions.dao

Dao

abstract class Dao[C <: Collection, Structure, Model, ID, Writer[_]] extends AnyRef

Base class for all DAO implementations. This class defines the API for all DAOs.

A DAO defines how to work with a specific collection.

C

Type of the collection.

Structure

The type that C operates on. BSONDocument or JsObject.

Model

Type of the model that this DAO uses.

ID

Type of the ID field of the model.

Writer

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Dao
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Dao(db: () ⇒ DB, collectionName: String)(implicit arg0: CollectionProducer[C])

    db

    A parameterless function returning a reactivemongo.api.DB instance.

    collectionName

    Name of the collection this DAO is going to operate on.

Abstract Value Members

  1. abstract def bulkInsert(models: TraversableOnce[Model], bulkSize: Int, bulkByteSize: Int): Future[Int]

    Bulk inserts multiple models.

    Bulk inserts multiple models.

    models

    A scala.collection.TraversableOnce of models.

    bulkSize
    bulkByteSize
    returns

    The number of successful insertions.

  2. abstract def count(selector: Structure): Future[Int]

    Returns the number of documents in this collection matching the given selector.

    Returns the number of documents in this collection matching the given selector.

    selector

    Selector document which may be empty.

  3. abstract def drop(): Future[Boolean]

    Drops this collection

  4. abstract def dropSync(timeout: Duration): Boolean

    Drops this collection and awaits until it has been dropped or a timeout has occured.

    Drops this collection and awaits until it has been dropped or a timeout has occured.

    timeout

    Maximum amount of time to await until this collection has been dropped.

    returns

    true if the collection has been successfully dropped, otherwise false.

  5. abstract def ensureIndexes(): Future[Traversable[Boolean]]

    Ensures indexes defined by autoIndexes.

  6. abstract def find(selector: Structure, sort: Structure, page: Int, pageSize: Int): Future[List[Model]]

    Retrieves models by page matching the given selector.

    Retrieves models by page matching the given selector.

    selector

    Selector document.

    sort

    Sorting document.

    page

    1 based page number.

    pageSize

    Maximum number of elements in each page.

  7. abstract def findAll(selector: Structure, sort: Structure): Future[List[Model]]

    Retrieves all models matching the given selector.

    Retrieves all models matching the given selector.

    selector

    Selector document.

    sort

    Sorting document.

  8. abstract def findAndRemove(query: Structure, sort: Structure): Future[Option[Model]]

    Removes and returns a single model.

    Removes and returns a single model.

    query

    The selection criteria for the remove.

    sort

    Determines which model the operation removes if the query selects multiple models. findAndRemove() removes the first model in the sort order specified by this argument.

  9. abstract def findAndUpdate(query: Structure, update: Structure, sort: Structure, fetchNewObject: Boolean, upsert: Boolean): Future[Option[Model]]

    Updates and returns a single model.

    Updates and returns a single model. It returns the old document by default.

    query

    The selection criteria for the update.

    update

    Performs an update of the selected model.

    sort

    Determines which model the operation updates if the query selects multiple models. findAndUpdate() updates the first model in the sort order specified by this argument.

    fetchNewObject

    When true, returns the updated model rather than the original.

    upsert

    When true, findAndUpdate() creates a new model if no model matches the query.

  10. abstract def findById(id: ID): Future[Option[Model]]

    Retrieves the model with the given id.

  11. abstract def findByIds(ids: ID*): Future[List[Model]]

    Retrieves the models with the given ids.

  12. abstract def findOne(selector: Structure): Future[Option[Model]]

    Retrieves at most one model matching the given selector.

  13. abstract def findRandom(selector: Structure): Future[Option[Model]]

    Retrieves a random model matching the given selector.

    Retrieves a random model matching the given selector.

    This API may require more than one query.

  14. abstract def fold[A](selector: Structure, sort: Structure, state: A)(f: (A, Model) ⇒ A): Future[A]

    Folds the documents matching the given selector by applying the function f.

    Folds the documents matching the given selector by applying the function f.

    A

    Type of fold result.

    selector

    Selector document.

    sort

    Sorting document.

    state

    Initial state for the fold operation.

    f

    Folding function.

  15. abstract def foreach(selector: Structure, sort: Structure)(f: (Model) ⇒ Unit): Future[Unit]

    Iterates over the documents matching the given selector and applies the function f.

    Iterates over the documents matching the given selector and applies the function f.

    selector

    Selector document.

    sort

    Sorting document.

    f

    function to be applied.

  16. abstract def insert(model: Model, writeConcern: GetLastError): Future[LastError]

    Inserts the given model.

  17. abstract def listIndexes(): Future[List[Index]]

    Lists indexes that are currently ensured in this collection.

    Lists indexes that are currently ensured in this collection.

    This list may not be equal to autoIndexes in case of index creation failure.

  18. abstract def remove(selector: Structure, writeConcern: GetLastError, firstMatchOnly: Boolean): Future[LastError]

    Removes model(s) matching the given selector.

    Removes model(s) matching the given selector.

    In order to remove multiple documents firstMatchOnly has to be false.

    selector

    Selector document.

    writeConcern

    Write concern defaults to defaultWriteConcern.

    firstMatchOnly

    Remove only the first matching document.

  19. abstract def removeAll(writeConcern: GetLastError): Future[LastError]

    Removes all documents in this collection.

  20. abstract def removeById(id: ID, writeConcern: GetLastError): Future[LastError]

    Removes the document with the given ID.

  21. abstract def save(model: Model, writeConcern: GetLastError): 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.

    model

    The model to save.

    writeConcern

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

  22. abstract def update[U](selector: Structure, update: U, writeConcern: GetLastError, upsert: Boolean, multi: Boolean)(implicit arg0: Writer[U]): Future[LastError]

    Updates the documents matching the given selector.

    Updates the documents matching the given selector.

    U

    Type of the update query.

    selector

    Selector query.

    update

    Update query.

    writeConcern

    Write concern which defaults to defaultWriteConcern.

    upsert

    Create the document if it does not exist.

    multi

    Update multiple documents.

  23. abstract def updateById[U](id: ID, update: U, writeConcern: GetLastError)(implicit arg0: Writer[U]): Future[LastError]

    Updates the document with the given id.

    Updates the document with the given id.

    U

    Type of the update query.

    id

    ID of the document that will be updated.

    update

    Update query.

    writeConcern

    Write concern which defaults to defaultWriteConcern.

Concrete 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. final def ==(arg0: AnyRef): Boolean

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

    Definition Classes
    Any
  6. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  7. def autoIndexes: Traversable[Index]

    The list of indexes to be ensured on DAO load.

    The list of indexes to be ensured on DAO load.

    Because of Scala initialization order there are exactly 2 ways of defining auto indexes.

    First way is to use an early definition:

    object PersonDao extends {
      override val autoIndexes = Seq(
        Index(Seq("name" -> IndexType.Ascending), unique = true, background = true),
        Index(Seq("age" -> IndexType.Ascending), background = true))
    } with BsonDao[Person, BSONObjectID](MongoContext.db, "persons")

    Second way is to override def. Be careful not to change declaration to val instead of def.

    object PersonDao extends BsonDao[Person, BSONObjectID](MongoContext.db, "persons") {
    
    override def autoIndexes = Seq(
      Index(Seq("name" -> IndexType.Ascending), unique = true, background = true),
      Index(Seq("age" -> IndexType.Ascending), background = true))
    }
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. def collection: C

    Reference to the collection this DAO operates on.

  10. def defaultWriteConcern: GetLastError

    Defines the default write concern for this Dao which defaults to GetLastError().

    Defines the default write concern for this Dao which defaults to GetLastError().

    Related API functions should allow overriding this value.

  11. implicit def ec: ExecutionContext

    Defines the scala.concurrent.ExecutionContext for this DAO.

    Defines the scala.concurrent.ExecutionContext for this DAO.

    Defaults to scala.concurrent.ExecutionContext.Implicits.global.

  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  15. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  16. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  17. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  18. final def ne(arg0: AnyRef): Boolean

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

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

    Definition Classes
    AnyRef
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  22. def toString(): String

    Definition Classes
    AnyRef → Any
  23. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped