the flag to bypass document validation during the operation
the ordered behaviour
the writer concern to be used
Prepares an UpdateCommand.UpdateElement
Prepares an UpdateCommand.UpdateElement
Prepares an UpdateCommand.UpdateElement
Prepares an UpdateCommand.UpdateElement
Updates many documents, according the ordered behaviour.
Updates many documents, according the ordered behaviour.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.bson.BSONDocument import reactivemongo.api.bson.collection.BSONCollection def updateMany( coll: BSONCollection, docs: Iterable[BSONDocument])(implicit ec: ExecutionContext) = { val update = coll.update(ordered = true) val elements = Future.sequence(docs.map { doc => update.element( q = BSONDocument("update" -> "selector"), u = BSONDocument(f"$$set" -> doc), upsert = true, multi = false) }) elements.flatMap { ups => update.many(ups) // Future[MultiBulkWriteResult] } }
Updates many documents, according the ordered behaviour.
Updates many documents, according the ordered behaviour.
import scala.concurrent.{ ExecutionContext, Future } import reactivemongo.api.bson.BSONDocument import reactivemongo.api.bson.collection.BSONCollection def updateMany( coll: BSONCollection, first: BSONDocument, docs: Iterable[BSONDocument])(implicit ec: ExecutionContext) = { val update = coll.update(ordered = true) val elements = Future.sequence(docs.map { doc => update.element( q = BSONDocument("update" -> "selector"), u = BSONDocument(f"$$set" -> doc), upsert = true, multi = false) }) for { first <- update.element( q = BSONDocument("update" -> "selector"), u = BSONDocument(f"$$set" -> first), upsert = true, multi = false) ups <- elements res <- update.many(ups) // Future[MultiBulkWriteResult] } yield res }
Performs a single update (see UpdateCommand.UpdateElement).
Performs a single update (see UpdateCommand.UpdateElement).
Performs a single update (see UpdateCommand.UpdateElement).
Builder for update operations.