DeleteBuilder
reactivemongo.api.collections.DeleteOps.DeleteBuilder
Builder for delete operations.
Attributes
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
Members list
Concise view
Value members
Concrete methods
Prepares an DeleteElement.
Prepares an DeleteElement.
Attributes
- collation
the collation
- limit
the maximum number of documents
- q
the query/selector
- See also:
final def many(deletes: Iterable[DeleteElement])(implicit ec: ExecutionContext): Future[MultiBulkWriteResult]
Performs a bulk operation using many deletes, each can delete multiple documents.
Performs a bulk operation using many deletes, each can delete multiple documents.
import scala.concurrent.{ ExecutionContext, Future }
import reactivemongo.api.bson.BSONDocument
import reactivemongo.api.bson.collection.BSONCollection
def bulkDelete(
coll: BSONCollection,
docs: Iterable[BSONDocument])(implicit ec: ExecutionContext) = {
val delete = coll.delete(ordered = true)
val elements = Future.sequence(docs.map { doc =>
delete.element(
q = doc,
limit = Some(1)) // only first match
})
elements.flatMap { ops =>
delete.many(ops) // Future[MultiBulkWriteResult]
}
}
Attributes
final def one[Q, U](q: Q, limit: Option[Int], collation: Option[Collation])(implicit ec: ExecutionContext, qw: Writer[Q]): Future[WriteResult]
Performs a delete with a one single selector (see DeleteElement).
This will delete all the documents matched by the q
selector.
Performs a delete with a one single selector (see DeleteElement).
This will delete all the documents matched by the q
selector.
Attributes
- collation
the collation
- limit
the maximum number of documents
- q
the query/selector