Package

reactivemongo

api

Permalink

package api

Visibility
  1. Public
  2. All

Type Members

  1. final class AsyncDriver extends AnyRef

    Permalink

    The asynchronous driver (see MongoConnection).

    The asynchronous driver (see MongoConnection).

    import scala.concurrent.Future
    import reactivemongo.api.{ AsyncDriver, MongoConnection }
    
    val driver = AsyncDriver()
    val connection: Future[MongoConnection] =
      driver.connect("mongodb://node:27017")
  2. sealed trait AuthenticationMode extends AnyRef

    Permalink

    The mode/mechanism of authentication

  3. final class Collation extends AnyRef

    Permalink

    Represents a collection, view, index or operation specific collation.

    Represents a collection, view, index or operation specific collation.

    import reactivemongo.api.Collation
    
    val collation = Collation(
      locale = "en-US",
      caseLevel = None,
      caseFirst = None,
      strength = Some(Collation.PrimaryStrength),
      numericOrdering = None,
      alternate = None,
      maxVariable = None,
      backwards = None)
  4. trait Collection extends AnyRef

    Permalink

    Basic information resolved for a MongoDB Collection, resolved from a reactivemongo.api.DB.

    Basic information resolved for a MongoDB Collection, resolved from a reactivemongo.api.DB.

    For collection operations, you should consider the generic API (reactivemongo.api.collections.GenericCollection).

  5. trait CollectionProducer[+C <: Collection] extends AnyRef

    Permalink

    A Producer of Collection implementation.

    A Producer of Collection implementation.

    This is used to get an implementation implicitly when getting a reference of a Collection.

  6. final class CollectionStats extends AnyRef

    Permalink

    Various information about a collection.

  7. trait Cursor[T] extends CursorCompatAPI[T]

    Permalink

    Cursor over results from MongoDB.

    Cursor over results from MongoDB.

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.Cursor
    import reactivemongo.api.bson.{ BSONDocument, Macros }
    import reactivemongo.api.bson.collection.BSONCollection
    
    case class User(name: String, pass: String)
    
    implicit val handler = Macros.reader[User]
    
    def findUsers(coll: BSONCollection)(
      implicit ec: ExecutionContext): Future[List[User]] =
      coll.find(BSONDocument("enabled" -> true)).
        cursor[User](). // obtain cursor for User results
        collect[List](
          maxDocs = 10,
          err = Cursor.FailOnError[List[User]]())
    T

    the type parsed from each result document

  8. trait CursorFlattener[C[_] <: Cursor[_]] extends AnyRef

    Permalink

    Flattening strategy for cursor.

    Flattening strategy for cursor.

    import scala.concurrent.Future
    
    import reactivemongo.api.{ Cursor, CursorFlattener }
    
    trait FooCursor[T] extends Cursor[T] { def foo: String }
    
    def flatFoo[T](future: Future[FooCursor[T]])(implicit cf: CursorFlattener[FooCursor]): FooCursor[T] = Cursor.flatten(future)
  9. trait CursorOps[T] extends AnyRef

    Permalink

    Internal cursor operations.

  10. final class CursorOptions extends AnyVal

    Permalink

  11. trait CursorProducer[T] extends AnyRef

    Permalink

    Allows to enrich a base cursor.

  12. final class DB extends DBMetaCommands with PackSupport[Pack]

    Permalink

    The reference to a MongoDB database, obtained from a reactivemongo.api.MongoConnection.

    The reference to a MongoDB database, obtained from a reactivemongo.api.MongoConnection.

    import scala.concurrent.ExecutionContext
    import reactivemongo.api.MongoConnection
    
    def foo(connection: MongoConnection)(implicit ec: ExecutionContext) = {
      val db = connection.database("plugin")
      val _ = db.map(_("acoll")) // Collection reference
    }
  13. final class FailoverStrategy extends AnyRef

    Permalink

    A failover strategy for sending requests.

    A failover strategy for sending requests. The default uses 10 retries: 125ms, 250ms, 375ms, 500ms, 625ms, 750ms, 875ms, 1s, 1125ms, 1250ms

    import scala.concurrent.duration._
    
    reactivemongo.api.FailoverStrategy(
      initialDelay = 150.milliseconds,
      retries = 20,
      delayFactor = { `try` => `try` * 1.5D })
  14. class FlattenedCursor[T] extends Cursor[T] with FlattenedCursorCompat[T]

    Permalink
  15. final class MongoConnection extends AnyRef

    Permalink

    A pool of MongoDB connections, obtained from a reactivemongo.api.AsyncDriver.

    A pool of MongoDB connections, obtained from a reactivemongo.api.AsyncDriver.

    Connection here does not mean that there is one open channel to the server: behind the scene, many connections (channels) are open on all the available servers in the replica set.

    Example:

    import scala.concurrent.ExecutionContext
    import reactivemongo.api._
    
    def foo(driver: AsyncDriver)(implicit ec: ExecutionContext) = {
      val con = driver.connect(List("localhost"))
      val db = con.flatMap(_.database("plugin"))
      val _ = db.map(_("acoll")) // Collection reference
    }
  16. final class MongoConnectionOptions extends AnyRef

    Permalink

    Options for MongoConnection (see more documentation).

    Annotations
    @SuppressWarnings()
  17. sealed trait ReadConcern extends AnyRef

    Permalink

    The Read Concern allows to control the consistency and isolation used to read data from replica sets.

    The Read Concern allows to control the consistency and isolation used to read data from replica sets.

    import reactivemongo.api.ReadConcern
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def queryBuilderWithReadConcern(coll: BSONCollection) =
      coll.find(BSONDocument.empty).
      readConcern(ReadConcern.Available)
  18. sealed trait ReadPreference extends AnyRef

    Permalink

    MongoDB read preference enables to read from primary or secondaries with a predefined strategy.

    MongoDB read preference enables to read from primary or secondaries with a predefined strategy.

    import reactivemongo.api.ReadPreference
    
    val pref: ReadPreference = ReadPreference.primary
  19. trait WrappedCursor[T] extends Cursor[T] with WrappedCursorCompat[T]

    Permalink

    Cursor wrapper, to help to define custom cursor classes.

    Cursor wrapper, to help to define custom cursor classes.

    See also

    CursorProducer

  20. trait WrappedCursorOps[T] extends CursorOps[T]

    Permalink

    Internal cursor operations.

  21. final class WriteConcern extends AnyRef

    Permalink

    The write concern.

    The write concern.

    import scala.concurrent.ExecutionContext
    import reactivemongo.api.{ DB, WriteConcern }
    import reactivemongo.api.bson.BSONDocument
    
    def foo(db: DB)(implicit ec: ExecutionContext) =
      db.collection("myColl").
        insert(ordered = false, WriteConcern.Acknowledged).
        one(BSONDocument("foo" -> "bar"))

Value Members

  1. object AsyncDriver

    Permalink

    The driver factory

  2. object ChangeStreams

    Permalink

    Change stream utilities.

    Change stream utilities.

    import scala.concurrent.{ ExecutionContext, Future }
    
    import reactivemongo.api.ChangeStreams.FullDocumentStrategy
    
    import reactivemongo.api.bson.BSONDocument
    import reactivemongo.api.bson.collection.BSONCollection
    
    def peekNext(
      coll: BSONCollection,
      strategy: FullDocumentStrategy)(
      implicit ec: ExecutionContext): Future[Option[BSONDocument]] =
      coll.watch[BSONDocument](fullDocumentStrategy = Some(strategy)).
        cursor.headOption
    
    def doIt(coll: BSONCollection)(
      implicit ec: ExecutionContext): Future[Unit] = for {
        _ <- peekNext(coll, FullDocumentStrategy.Default)
        _ <- peekNext(coll, FullDocumentStrategy.UpdateLookup)
      } yield ()
    See also

    reactivemongo.api.collections.GenericCollection.watch

  3. object Collation

    Permalink

    Collation utilities.

  4. object Cursor

    Permalink

    Cursor companion object

  5. object CursorFlattener

    Permalink

    Flatteners helper

  6. object CursorOps

    Permalink
  7. object CursorOptions

    Permalink
  8. object CursorProducer

    Permalink
  9. object FailoverStrategy

    Permalink

    FailoverStrategy utilities

  10. object MongoConnection

    Permalink

  11. object MongoConnectionOptions

    Permalink

    MongoConnectionOptions factory.

    MongoConnectionOptions factory.

    reactivemongo.api.MongoConnectionOptions(nbChannelsPerNode = 10)
  12. object ReadConcern

    Permalink
  13. object ReadPreference

    Permalink

    ReadPreference utilities and factories.

  14. object ScramSha1Authentication extends AuthenticationMode with ScramAuthentication with Product with Serializable

    Permalink

    SCRAM-SHA-1 authentication (since MongoDB 3.6)

  15. object ScramSha256Authentication extends AuthenticationMode with ScramAuthentication with Product with Serializable

    Permalink

    SCRAM-SHA-256 authentication (see MongoDB 4.0)

  16. object Version

    Permalink
  17. object WriteConcern

    Permalink

    WriteConcern utilities.

  18. object X509Authentication extends AuthenticationMode with Product with Serializable

    Permalink

    X509 authentication

  19. package bson

    Permalink
  20. package collections

    Permalink
  21. package commands

    Permalink
  22. package gridfs

    Permalink
  23. package indexes

    Permalink

Ungrouped