Then mode of authentication against the replica set.
A MongoDB Collection.
A MongoDB Collection. You should consider the generic API (reactivemongo.api.collections.GenericCollection) and the default reactivemongo.api.collections.bson.BSONCollection.
import reactivemongo.bson._ import reactivemongo.api.collections.bson.BSONCollection 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[BSONCollection]("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)) } } } }
A mixin that provides commands about this Collection itself.
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.
Cursor over results from MongoDB.
Cursor over results from MongoDB.
the type parsed from each result document
Flattening strategy for cursor.
Allows to enrich a base cursor.
A Mongo Database.
A Mongo Database.
You should consider the provided reactivemongo.api.DefaultDB implementation.
Example:
import reactivemongo.api._ val connection = MongoConnection( List( "localhost:27016" ) ) val db = connection.database("plugin") val collection = db("acoll")
A mixin that provides commands about this database itself.
The default DB implementation, that mixes in the database traits.
A helper that sends the given message to the given actor, following a failover strategy.
A helper that sends the given message to the given actor, following a failover strategy. This helper holds a future reference that is completed with a response, after 1 or more attempts (specified in the given strategy). If the all the tryouts configured by the given strategy were unsuccessful, the future reference is completed with a Throwable.
Should not be used directly for most use cases.
Type of the message to send.
A failover strategy for sending requests.
A failover strategy for sending requests. The default uses 8 retries: 125ms, 250ms, 375ms, 500ms, 625ms, 750ms, 875ms, 1s
the initial delay between the first failed attempt and the next one.
the number of retries to do before giving up.
a function that takes the current iteration and returns a factor to be applied to the initialDelay.
A pool of MongoDB connections.
A pool of MongoDB connections.
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 reactivemongo.api._ val connection = MongoConnection(List("localhost")) val db = connection.database("plugin") val collection = db.map(_.("acoll"))
Options for MongoConnection.
Options for MongoConnection.
The number of milliseconds to wait for a connection to be established before giving up.
The database source for authentication credentials.
Enable SSL connection (required to be accepted on server-side).
If sslEnabled
is true, this one indicates whether to accept invalid certificates (e.g. self-signed).
Either CrAuthentication or ScramSha1Authentication
TCPNoDelay flag (ReactiveMongo-specific option). The default value is false (see TCP_NODELAY).
TCP KeepAlive flag (ReactiveMongo-specific option). The default value is false (see SO_KEEPALIVE).
Number of channels (connections) per node (ReactiveMongo-specific option).
the default write concern
the default read preference
the default failover strategy
the interval in milliseconds used by monitor to refresh the node set (default: 10000)
the time in milliseconds to attempt a send or receive on a socket before the attempt times out (default: 0 for no timeout)
A helper to make the query options.
A helper to make the query options. You may use the methods to set the fields of this class, or set them directly.
the number of documents to skip.
the upper limit on the number of documents to retrieve per batch.
the query flags
MongoDB Read Preferences enable to read from primary or secondaries with a predefined strategy.
Cursor wrapper, to help to define custom cursor classes.
Cursor wrapper, to help to define custom cursor classes.
CursorProducer
(Since version 0.11.11) Will be made private
(Since version 0.11.10) Will be removed
The default serialization pack.
MongoDB-CR authentication
Cursor companion object
Flatteners helper
The driver factory
SCRAM-SHA-1 authentication (see MongoDB 3.0)