UpdateBuilder

reactivemongo.api.collections.UpdateOps.UpdateBuilder
sealed trait UpdateBuilder

Builder for update operations.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Concise view

Value members

Abstract methods

the flag to bypass document validation during the operation

the flag to bypass document validation during the operation

Attributes

the maximum number of document(s) per bulk

the maximum number of document(s) per bulk

Attributes

Returns an update builder with the given maxBulkSize.

Returns an update builder with the given maxBulkSize.

Attributes

the ordered behaviour

the ordered behaviour

Attributes

the writer concern to be used

the writer concern to be used

Attributes

Concrete methods

final def element[Q, U](q: Q, u: U, upsert: Boolean, multi: Boolean)(implicit qw: Writer[Q], uw: Writer[U]): Future[UpdateElement]

Prepares an UpdateElement

Prepares an UpdateElement

Attributes

final def element[Q, U](q: Q, u: U, upsert: Boolean, multi: Boolean, collation: Option[Collation])(implicit qw: Writer[Q], uw: Writer[U]): Future[UpdateElement]

Prepares an UpdateElement

Prepares an UpdateElement

Attributes

final def element[Q, U](q: Q, u: U, upsert: Boolean, multi: Boolean, collation: Option[Collation], arrayFilters: Seq[Document])(implicit qw: Writer[Q], uw: Writer[U]): Future[UpdateElement]

Prepares an UpdateElement

Prepares an UpdateElement

Attributes

final def many(firstUpdate: UpdateElement, updates: Iterable[UpdateElement])(implicit ec: ExecutionContext): 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
}

Attributes

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]
 }
}

Attributes

final def one[Q, U](q: Q, u: U, upsert: Boolean, multi: Boolean)(implicit ec: ExecutionContext, qw: Writer[Q], uw: Writer[U]): Future[UpdateWriteResult]

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)

Attributes

final def one[Q, U](q: Q, u: U, upsert: Boolean, multi: Boolean, collation: Option[Collation])(implicit ec: ExecutionContext, qw: Writer[Q], uw: Writer[U]): Future[UpdateWriteResult]

Performs a single update (see UpdateElement).

Performs a single update (see UpdateElement).

Attributes

final def one[Q, U](q: Q, u: U, upsert: Boolean, multi: Boolean, collation: Option[Collation], arrayFilters: Seq[Document])(implicit ec: ExecutionContext, qw: Writer[Q], uw: Writer[U]): Future[UpdateWriteResult]

Performs a single update (see UpdateElement).

Performs a single update (see UpdateElement).

Attributes

final def one[Q](q: Q, u: Pipeline, upsert: Boolean, multi: Boolean, collation: Option[Collation], arrayFilters: Seq[Document])(implicit ec: ExecutionContext, qw: Writer[Q]): Future[UpdateWriteResult]

Performs a single update (see UpdateElement) with a aggregation pipeline.

Performs a single update (see UpdateElement) with a aggregation pipeline.

Attributes

Since:

MongoDB 4.2

Deprecated methods

final def element[Q](q: Q, u: Pipeline, upsert: Boolean, multi: Boolean, collation: Option[Collation])(implicit qw: Writer[Q]): Future[UpdateElement]

'''EXPERIMENTAL:''' Prepares an UpdateElement with an update pipeline.

'''EXPERIMENTAL:''' Prepares an UpdateElement with an update pipeline.

Attributes

Since:

MongoDB 4.2

Deprecated
true
final def element[Q](q: Q, u: Pipeline, upsert: Boolean, multi: Boolean, collation: Option[Collation], arrayFilters: Seq[Document])(implicit qw: Writer[Q]): Future[UpdateElement]

'''EXPERIMENTAL:''' Prepares an UpdateElement with an update pipeline.

'''EXPERIMENTAL:''' Prepares an UpdateElement with an update pipeline.

Attributes

Since:

MongoDB 4.2

Deprecated
true
final def one[Q](q: Q, u: Pipeline, upsert: Boolean, multi: Boolean)(implicit ec: ExecutionContext, qw: Writer[Q]): Future[UpdateWriteResult]

'''EXPERIMENTAL:''' Performs a single update (see UpdateElement) with a aggregation pipeline.

'''EXPERIMENTAL:''' Performs a single update (see UpdateElement) with a aggregation pipeline.

Attributes

Since:

MongoDB 4.2

Deprecated
true
final def one[Q](q: Q, u: Pipeline, upsert: Boolean)(implicit ec: ExecutionContext, qw: Writer[Q]): Future[UpdateWriteResult]

'''EXPERIMENTAL:''' Performs a single update (see UpdateElement) with a aggregation pipeline.

'''EXPERIMENTAL:''' Performs a single update (see UpdateElement) with a aggregation pipeline.

Attributes

Since:

MongoDB 4.2

Deprecated
true
final def one[Q](q: Q, u: Pipeline)(implicit ec: ExecutionContext, qw: Writer[Q]): Future[UpdateWriteResult]

'''EXPERIMENTAL:''' Performs a single update (see UpdateElement) with a aggregation pipeline.

'''EXPERIMENTAL:''' Performs a single update (see UpdateElement) with a aggregation pipeline.

Attributes

Since:

MongoDB 4.2

Deprecated
true
final def one(update: UpdateElement)(implicit ec: ExecutionContext): Future[UpdateWriteResult]

Attributes

Deprecated
true