reactivemongo.api
Members list
Type members
Classlikes
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")
Attributes
- classLoader
a classloader used to load the actor system
- config
a custom configuration (otherwise the default options are used)
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
The driver factory
The driver factory
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- AsyncDriver.type
The mode/mechanism of authentication
The mode/mechanism of authentication
Attributes
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
- object ScramSha1Authentication.typeobject ScramSha256Authentication.typeobject X509Authentication.type
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 ()
Attributes
- See also:
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- ChangeStreams.type
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)
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
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).
Attributes
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
- trait GenericCollection[P]
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.
Attributes
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
- object BSONCollectionProducer.type
Various information about a collection.
Various information about a collection.
Attributes
- averageObjectSize
The average object size in bytes (or in bytes / scale, if any).
- capped
States if this collection is capped.
- count
The number of documents in this collection.
- indexSizes
Size of specific indexes in bytes.
- lastExtentSize
Size of the most recently created extent (only for mmapv1 storage engine).
- max
The maximum number of documents of this collection, if capped.
- maxSize
The maximum size in bytes (or in bytes / scale, if any) of this collection, if capped.
- nindexes
Number of indexes.
- ns
The fully qualified collection name.
- numExtents
Number of extents (contiguously allocated chunks of datafile space, only for mmapv1 storage engine).
- paddingFactor
Padding can speed up updates if documents grow (only for mmapv1 storage engine).
- size
The size in bytes (or in bytes / scale, if any).
- storageSize
Preallocated space for the collection.
- systemFlags
System flags.
- userFlags
User flags.
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Cursor over results from MongoDB.
Cursor over results from MongoDB.
import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.Cursor
import reactivemongo.api.bson.{ BSONDocument, BSONDocumentReader, Macros }
import reactivemongo.api.bson.collection.BSONCollection
case class User(name: String, pass: String)
implicit val reader: BSONDocumentReader[User] = 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]]())
Attributes
- T
the type parsed from each result document
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
- class FlattenedCursor[T]trait WrappedCursor[T]
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)
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
- object defaultCursorFlattener.type
Flatteners helper
Flatteners helper
Attributes
- Companion:
- trait
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- CursorFlattener.type
Internal cursor operations.
Internal cursor operations.
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
- trait WrappedCursorOps[T]
- Self type
- Cursor[T]
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- CursorOptions.type
Allows to enrich a base cursor.
Allows to enrich a base cursor.
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Attributes
- Companion:
- trait
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- CursorProducer.type
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
}
Attributes
- connection
the reactivemongo.api.MongoConnection that will be used to query this database
- failoverStrategy
the default failover strategy for sending requests
- name
this database name
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
A failover strategy for sending requests. The default uses 10 retries: 125ms, 250ms, 375ms, 500ms, 625ms, 750ms, 875ms, 1s, 1125ms, 1250ms
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 })
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
FailoverStrategy utilities
FailoverStrategy utilities
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- FailoverStrategy.type
Attributes
- Graph
- Supertypes
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
}
Attributes
- mongosystem
the reference to the internal reactivemongo.core.actors.MongoDBSystem Actor.
- name
the unique name for the connection pool
- supervisor
the name of the supervisor
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- MongoConnection.type
Options for MongoConnection (see more documentation).
Options for MongoConnection (see more documentation).
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
MongoConnectionOptions factory.
MongoConnectionOptions factory.
reactivemongo.api.MongoConnectionOptions(nbChannelsPerNode = 10)
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
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)
Attributes
Attributes
- Companion:
- trait
- Graph
- Supertypes
- trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
- ReadConcern.type
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
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Known subtypes
ReadPreference utilities and factories.
ReadPreference utilities and factories.
Attributes
- Companion:
- trait
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- ReadPreference.type
SCRAM-SHA-1 authentication (since MongoDB 3.6)
SCRAM-SHA-1 authentication (since MongoDB 3.6)
Attributes
- Graph
- Supertypes
- trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait AuthenticationModeclass Objecttrait Matchableclass Any
- Self type
SCRAM-SHA-256 authentication (see MongoDB 4.0)
SCRAM-SHA-256 authentication (see MongoDB 4.0)
Attributes
- Graph
- Supertypes
- trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait AuthenticationModeclass Objecttrait Matchableclass Any
- Self type
Cursor wrapper, to help to define custom cursor classes.
Cursor wrapper, to help to define custom cursor classes.
Attributes
- See also:
CursorProducer
- Graph
- Supertypes
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"))
Attributes
- Companion:
- object
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
WriteConcern utilities.
WriteConcern utilities.
Attributes
- Companion:
- class
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
- WriteConcern.type
X509 authentication
X509 authentication
Attributes
- Graph
- Supertypes
- trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalstrait AuthenticationModeclass Objecttrait Matchableclass Any
- Self type
- X509Authentication.type