Toggles AwaitData: Block a little while waiting for more data instead of returning immediately if no data.
Toggles AwaitData: Block a little while waiting for more data instead of returning immediately if no data. Use along with TailableCursor.
Sets an upper limit on the number of documents to retrieve per batch.
Sets an upper limit on the number of documents to retrieve per batch. Defaults to 0 (meaning no upper limit - MongoDB decides).
Adds a comment to this query, that may appear in the MongoDB logs.
Adds a comment to this query, that may appear in the MongoDB logs.
Returns a Cursor for the result of this query.
Returns a Cursor for the result of this query.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.Cursor import reactivemongo.api.bson.BSONDocument import reactivemongo.api.bson.collection.BSONCollection def findAllVisible(coll: BSONCollection)( implicit ec: ExecutionContext): Future[List[BSONDocument]] = coll.find(BSONDocument("visible" -> true)). cursor[BSONDocument]().collect[List]( maxDocs = 10, err = Cursor.FailOnError[List[BSONDocument]]())
the results type
The reactivemongo.api.ReadPreference for this query. If the ReadPreference
implies that this query can be run on a secondary, the slaveOk flag will be set.
the reader for the results type
Toggles Exhaust
Toggles Exhaust
Toggles explain mode.
Toggles explain mode.
Sets the hint document (a document that declares the index MongoDB should use for this query).
Sets the hint document (a document that declares the index MongoDB should use for this query).
Adds maxTimeMs to query
Adds maxTimeMs to query
Toggles NoCursorTimeout: The cursor will not expire automatically
Toggles NoCursorTimeout: The cursor will not expire automatically
Sends this query and gets a future Option[T]
(alias for reactivemongo.api.Cursor.headOption).
Sends this query and gets a future Option[T]
(alias for reactivemongo.api.Cursor.headOption).
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.ReadPreference import reactivemongo.api.bson.BSONDocument import reactivemongo.api.bson.collection.BSONCollection def findUser(coll: BSONCollection, name: String)( implicit ec: ExecutionContext): Future[Option[BSONDocument]] = coll.find(BSONDocument("user" -> name)). one[BSONDocument](ReadPreference.primaryPreferred)
the results type
The reactivemongo.api.ReadPreference for this query. If the ReadPreference
implies that this query can be run on a secondary, the slaveOk flag will be set.
the reader for the results type
Sends this query and gets a future Option[T]
(alias for reactivemongo.api.Cursor.headOption) (using the default reactivemongo.api.ReadPreference).
Sends this query and gets a future Option[T]
(alias for reactivemongo.api.Cursor.headOption) (using the default reactivemongo.api.ReadPreference).
import scala.concurrent.{ ExecutionContext, Future } 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 findUser(coll: BSONCollection, name: String)( implicit ec: ExecutionContext): Future[Option[User]] = coll.find(BSONDocument("user" -> name)).one[User]
the results type
the reader for the results type
Toggles OplogReplay
Toggles OplogReplay
Toggles Partial: The response can be partial - if a shard is down, no error will be thrown.
Toggles Partial: The response can be partial - if a shard is down, no error will be thrown.
Sets the projection specification to determine which fields to include in the returned documents.
Sets the projection specification to determine which fields to include in the returned documents.
Sets the projection specification to determine which fields to include in the returned documents.
Sets the projection specification to determine which fields to include in the returned documents.
The type of the projection. An implicit Writer[Pjn]
typeclass for handling it has to be in the scope.
The read concern (since 3.2)
The read concern (since 3.2)
Sends this query and gets a future T
(alias for reactivemongo.api.Cursor.head).
Sends this query and gets a future T
(alias for reactivemongo.api.Cursor.head).
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.ReadPreference import reactivemongo.api.bson.{ BSONDocument, Macros } import reactivemongo.api.bson.collection.BSONCollection case class User(name: String, pass: String) implicit val handler = Macros.handler[User] def findUser(coll: BSONCollection, name: String)( implicit ec: ExecutionContext): Future[User] = coll.find(BSONDocument("user" -> name)). requireOne[User](ReadPreference.primaryPreferred)
the results type
The reactivemongo.api.ReadPreference for this query. If the ReadPreference
implies that this query can be run on a secondary, the slaveOk flag will be set.
the reader for the results type
Sends this query and gets a future T
(alias for reactivemongo.api.Cursor.head)
(using the default reactivemongo.api.ReadPreference).
Sends this query and gets a future T
(alias for reactivemongo.api.Cursor.head)
(using the default reactivemongo.api.ReadPreference).
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.bson.BSONDocument import reactivemongo.api.bson.collection.BSONCollection def findUser(coll: BSONCollection, name: String)( implicit ec: ExecutionContext): Future[BSONDocument] = coll.find(BSONDocument("user" -> name)).requireOne[BSONDocument]
the results type
the reader for the results type
Sets the number of documents to skip.
Sets the number of documents to skip.
Toggles SlaveOk: The query is might be run on a secondary.
Toggles SlaveOk: The query is might be run on a secondary.
Toggles snapshot mode.
Toggles snapshot mode.
Sets the sort specification for the ordering of the results.
Sets the sort specification for the ordering of the results.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.Cursor import reactivemongo.api.bson.BSONDocument import reactivemongo.api.bson.collection.BSONCollection def findSortedVisible(coll: BSONCollection)( implicit ec: ExecutionContext): Future[List[BSONDocument]] = coll.find(BSONDocument("visible" -> true)). sort(BSONDocument("age" -> 1)). // sort per age cursor[BSONDocument](). collect[List]( maxDocs = 100, err = Cursor.FailOnError[List[BSONDocument]]())
Toggles TailableCursor: Makes the cursor not to close after all the data is consumed.
Toggles TailableCursor: Makes the cursor not to close after all the data is consumed.
Sets the query predicate; If unspecified, then all documents in the collection will match the predicate.
Sets the query predicate; If unspecified, then all documents in the collection will match the predicate.
(Since version 0.19.4) Specify the filter predicate using collection.find(..)
Sets the query predicate; If unspecified, then all documents in the collection will match the predicate.
Sets the query predicate; If unspecified, then all documents in the collection will match the predicate.
The type of the query. An implicit Writer[Qry]
typeclass for handling it has to be in the scope.
(Since version 0.19.4) Specify the filter predicate using collection.find(..)
(Since version 0.18.2) Use filter
(Since version 0.18.2) Use filter
The default ReadPreference
The default ReadPreference
(Since version 0.16.0) Internal: will be made private
(Since version 0.12.4) Use options
or the separate query ops
(Since version 0.16.0) Useless, will be remove