the flag to bypass document validation during the operation
Returns an update builder with the given maxBulkSize
.
the maximum number of document(s) per bulk
the ordered behaviour
the writer concern to be used
Prepares an UpdateElement
Prepares an UpdateElement
Prepares an 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 { _ <- 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 UpdateElement) with a aggregation pipeline.
Performs a single update (see UpdateElement) with a aggregation pipeline.
MongoDB 4.2
Performs a single update (see UpdateElement).
Performs a single update (see UpdateElement).
Performs a single update (see UpdateElement).
Performs a single update (see UpdateElement).
import scala.concurrent.ExecutionContext.Implicits.global import reactivemongo.api.bson.BSONDocument import reactivemongo.api.bson.collection.BSONCollection def updateOne(coll: BSONCollection, q: BSONDocument, u: BSONDocument) = coll.update.one(q, u, upsert = true)
EXPERIMENTAL: Prepares an UpdateElement with an update pipeline.
EXPERIMENTAL: Prepares an UpdateElement with an update pipeline.
(Since version 1.0.5-SNAPSHOT) Experimental
MongoDB 4.2
EXPERIMENTAL: Prepares an UpdateElement with an update pipeline.
EXPERIMENTAL: Prepares an UpdateElement with an update pipeline.
(Since version 1.0.5-SNAPSHOT) Experimental
MongoDB 4.2
(Since version 1.0.5) Experimental
EXPERIMENTAL: Performs a single update (see UpdateElement) with a aggregation pipeline.
EXPERIMENTAL: Performs a single update (see UpdateElement) with a aggregation pipeline.
(Since version 1.0.5-SNAPSHOT) Experimental
MongoDB 4.2
EXPERIMENTAL: Performs a single update (see UpdateElement) with a aggregation pipeline.
EXPERIMENTAL: Performs a single update (see UpdateElement) with a aggregation pipeline.
(Since version 1.0.5-SNAPSHOT) Experimental
MongoDB 4.2
EXPERIMENTAL: Performs a single update (see UpdateElement) with a aggregation pipeline.
EXPERIMENTAL: Performs a single update (see UpdateElement) with a aggregation pipeline.
(Since version 1.0.5-SNAPSHOT) Experimental
MongoDB 4.2
Builder for update operations.