Alias for BatchCommands.AggregationFramework.PipelineOperator
The database which this collection belong to.
The database which this collection belong to.
The default failover strategy for the methods of this collection.
The default failover strategy for the methods of this collection.
The name of the collection.
The name of the collection.
Aggregates the matching documents.
Aggregates the matching documents.
import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global import reactivemongo.bson._ import reactivemongo.api.collections.bson.BSONCollection def populatedStates(cities: BSONCollection): Future[List[BSONDocument]] = { import cities.BatchCommands.AggregationFramework import AggregationFramework.{ Group, Match, SumField } cities.aggregate(Group(BSONString("$state"))( "totalPop" -> SumField("population")), List( Match(document("totalPop" -> document("$gte" -> 10000000L))))).map(_.documents) }
the first operator of the pipeline
the sequence of MongoDB aggregation operations
specifies to return the information on the processing of the pipeline
enables writing to temporary files
enables to bypass document validation during the operation
the read concern
Aggregates the matching documents.
Aggregates the matching documents.
import scala.concurrent.Future import scala.concurrent.ExecutionContext.Implicits.global import reactivemongo.bson._ import reactivemongo.api.Cursor import reactivemongo.api.collections.bson.BSONCollection def populatedStates(cities: BSONCollection): Future[Cursor[BSONDocument]] = { import cities.BatchCommands.AggregationFramework import AggregationFramework.{ Cursor => AggCursor, Group, Match, SumField } val cursor = AggCursor(batchSize = 1) // initial batch size cities.aggregate1[BSONDocument](Group(BSONString("$state"))( "totalPop" -> SumField("population")), List( Match(document("totalPop" -> document("$gte" -> 10000000L)))), cursor) }
the result type
the first operator of the pipeline
the sequence of MongoDB aggregation operations
the cursor object for aggregation
specifies to return the information on the processing of the pipeline
enables writing to temporary files
enables to bypass document validation during the operation
the read concern of the aggregation
the read preference for the result cursor
Gets another implementation of this collection.
Gets another implementation of this collection. An implicit CollectionProducer[C] must be present in the scope, or it will be the default implementation (reactivemongo.api.collections.bson.BSONCollection).
Overrides the default strategy.
Converts this collection to a capped one.
Converts this collection to a capped one.
The size of this capped collection, in bytes.
The maximum number of documents this capped collection can contain.
Count the documents matching the given criteria.
Count the documents matching the given criteria.
This method accepts any query or hint, the scope provides instances of appropriate typeclasses.
Please take a look to the mongodb documentation to know how querying works.
the type of hint. An implicit H => Hint
conversion has to be in the scope.
the query selector
the maximum number of matching documents to count
the number of matching documents to skip before counting
the index to use (either the index name or the index document)
Creates this collection.
Creates this collection.
The returned future will be completed with an error if this collection already exists.
States if should automatically add an index on the _id field. By default, regular collections will have an indexed _id field, in contrast to capped collections.
Creates this collection as a capped one.
Creates this collection as a capped one.
The returned future will be completed with an error if this collection already exists.
the byte size of the collections.
the maximum number of documents.
States if should automatically add an index on the _id field. By default, capped collections will NOT have an indexed _id field, in contrast to regular collections.
Returns the distinct values for a specified field across a single collection.
Returns the distinct values for a specified field across a single collection.
the element type of the distinct values
the container, that must be a Iterable
the field for which to return distinct values
the query selector that specifies the documents from which to retrieve the distinct values.
the read concern
val distinctStates = collection.distinct[String, Set]("state")
Drops this collection.
Drops this collection.
If the collection existed and is successfully dropped, the returned future will be completed with true.
If failIfNotFound
is false and the collection doesn't exist,
the returned future will be completed with false.
Otherwise in case, the future will be completed with the encountered error.
Find the documents matching the given criteria.
Find the documents matching the given criteria.
This method accepts any selector and projection object, provided that there is an implicit Writer[S]
typeclass for handling them in the scope.
Please take a look to the mongodb documentation to know how querying works.
the type of the selector (the query). An implicit Writer[S]
typeclass for handling it has to be in the scope.
the type of the projection object. An implicit Writer[P]
typeclass for handling it has to be in the scope.
the query selector.
Get only a subset of each matched documents. Defaults to None.
a GenericQueryBuilder that you can use to to customize the query. You can obtain a cursor by calling the method reactivemongo.api.Cursor on this query builder.
Find the documents matching the given criteria.
Find the documents matching the given criteria.
This method accepts any query and projection object, provided that there is an implicit Writer[S]
typeclass for handling them in the scope.
Please take a look to the mongodb documentation to know how querying works.
the type of the selector (the query). An implicit Writer[S]
typeclass for handling it has to be in the scope.
a GenericQueryBuilder that you can use to to customize the query. You can obtain a cursor by calling the method reactivemongo.api.Cursor on this query builder.
Applies a findAndModify operation.
Applies a findAndModify operation. See findAndUpdate and findAndRemove convenient functions.
val updateOp = collection.updateModifier( BSONDocument("$set" -> BSONDocument("age" -> 35))) val personBeforeUpdate: Future[Person] = collection.findAndModify(BSONDocument("name" -> "Joline"), updateOp). map(_.result[Person]) val removedPerson: Future[Person] = collection.findAndModify( BSONDocument("name" -> "Jack"), collection.removeModifier)
the query selector
the modify operator to be applied
the optional document possibly indicating the sort criterias
the field projection
Finds some matching document, and removes it (using findAndModify).
Finds some matching document, and removes it (using findAndModify).
val removed: Future[Person] = collection.findAndRemove( BSONDocument("name" -> "Foo")).map(_.result[Person])
the query selector
the optional document possibly indicating the sort criterias
the field projection
Finds some matching document, and updates it (using findAndModify).
Finds some matching document, and updates it (using findAndModify).
val person: Future[BSONDocument] = collection.findAndUpdate( BSONDocument("name" -> "James"), BSONDocument("$set" -> BSONDocument("age" -> 17)), fetchNewObject = true) // on success, return the update document: // { "age": 17 }
the query selector
the update to be applied
the command result must be the new object instead of the old one.
if true, creates a new document if no document matches the query, or if documents match the query, findAndModify performs an update
the optional document possibly indicating the sort criterias
the field projection
Gets the full qualified name of this collection.
Gets the full qualified name of this collection.
Returns an index manager for this collection.
Returns an index manager for this collection.
Inserts a document into the collection and wait for the reactivemongo.api.commands.WriteResult.
Inserts a document into the collection and wait for the reactivemongo.api.commands.WriteResult.
Please read the documentation about reactivemongo.core.commands.GetLastError to know how to use it properly.
the type of the document to insert. An implicit Writer[T]
typeclass for handling it has to be in the scope.
the document to insert.
the reactivemongo.core.commands.GetLastError command message to send in order to control how the document is inserted. Defaults to GetLastError().
a future reactivemongo.api.commands.WriteResult that can be used to check whether the insertion was successful.
Remove the matched document(s) from the collection and wait for the reactivemongo.api.commands.WriteResult result.
Remove the matched document(s) from the collection and wait for the reactivemongo.api.commands.WriteResult result.
Please read the documentation about reactivemongo.core.commands.GetLastError to know how to use it properly.
the type of the selector of documents to remove. An implicit Writer[T]
typeclass for handling it has to be in the scope.
the selector of documents to remove.
the reactivemongo.core.commands.GetLastError command message to send in order to control how the documents are removed. Defaults to GetLastError().
states whether only the first matched documents has to be removed from this collection.
a future reactivemongo.api.commands.WriteResult that can be used to check whether the removal was successful.
Returns a removal modifier, to be used with findAndModify.
Renames this collection.
Renames this collection.
The new name of this collection.
If a collection of name to
already exists, then drops that collection before renaming this one.
Gets another collection in the current database.
Gets another collection in the current database. An implicit CollectionProducer[C] must be present in the scope, or it will be the default implementation (reactivemongo.api.collections.bson.BSONCollection).
The other collection name.
Overrides the default strategy.
Returns various information about this collection.
Returns various information about this collection.
A scale factor (for example, to get all the sizes in kilobytes).
Returns various information about this collection.
Returns various information about this collection.
Inserts a document into the collection without writeConcern.
Inserts a document into the collection without writeConcern.
Please note that you cannot be sure that the document has been effectively written and when (hence the Unit return type).
the type of the document to insert. An implicit Writer[T]
typeclass for handling it has to be in the scope.
the document to insert.
Remove the matched document(s) from the collection without writeConcern.
Remove the matched document(s) from the collection without writeConcern.
Please note that you cannot be sure that the matched documents have been effectively removed and when (hence the Unit return type).
the type of the selector of documents to remove. An implicit Writer[T]
typeclass for handling it has to be in the scope.
the selector of documents to remove.
states whether only the first matched documents has to be removed from this collection.
Updates one or more documents matching the given selector with the given modifier or update object.
Updates one or more documents matching the given selector with the given modifier or update object.
Please note that you cannot be sure that the matched documents have been effectively updated and when (hence the Unit return type).
the type of the selector object. An implicit Writer[S]
typeclass for handling it has to be in the scope.
the type of the modifier or update object. An implicit Writer[U]
typeclass for handling it has to be in the scope.
the selector object, for finding the documents to update.
the modifier object (with special keys like $set) or replacement object.
states whether the update objet should be inserted if no match found. Defaults to false.
states whether the update may be done on all the matching documents.
Updates one or more documents matching the given selector with the given modifier or update object.
Updates one or more documents matching the given selector with the given modifier or update object.
the type of the selector object. An implicit Writer[S]
typeclass for handling it has to be in the scope.
the type of the modifier or update object. An implicit Writer[U]
typeclass for handling it has to be in the scope.
the selector object, for finding the documents to update.
the modifier object (with special keys like $set) or replacement object.
the reactivemongo.core.commands.GetLastError command message to send in order to control how the documents are updated. Defaults to GetLastError().
states whether the update objet should be inserted if no match found. Defaults to false.
states whether the update may be done on all the matching documents.
a future reactivemongo.api.commands.WriteResult that can be used to check whether the update was successful.
Returns an update modifier, to be used with findAndModify.
Returns an update modifier, to be used with findAndModify.
the update to be applied
the command result must be the new object instead of the old one.
if true, creates a new document if no document matches the query, or if documents match the query, findAndModify performs an update
Drops this collection.
Drops this collection.
The returned future will be completed with an error if this collection does not exist.
(Since version 0.12.0) Use drop(Boolean)
If this collection is capped, removes all the documents it contains.
If this collection is capped, removes all the documents it contains.
Deprecated because it became an internal command, unavailable by default.
(Since version 0.9) Deprecated because emptyCapped became an internal command, unavailable by default.
Gets another collection in the current database.
Gets another collection in the current database. An implicit CollectionProducer[C] must be present in the scope, or it will be the default implementation (reactivemongo.api.collections.bson.BSONCollection).
The other collection name.
Overrides the default strategy.
(Since version 0.10) Consider using sibling
instead
A Collection that provides default methods using a
SerializationPack
(e.g. the default reactivemongo.api.BSONSerializationPack).Some methods of this collection accept instances of
Reader[T]
andWriter[T]
, that transform anyT
instance into a document, compatible with the selected serialization pack, and vice-versa.the serialization pack