the ordered behaviour
the writer concern to be used
Prepares an DeleteElement.
Prepares an DeleteElement.
the query/selector
the maximum number of documents
the collation
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] } }
Performs a delete with a one single selector (see DeleteElement).
Performs a delete with a one single selector (see DeleteElement).
This will delete all the documents matched by the q
selector.
the query/selector
the maximum number of documents
the collation
Builder for delete operations.