InsertBuilder

reactivemongo.api.collections.InsertOps.InsertBuilder
sealed trait InsertBuilder

Builder for insert 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 (default: false)

the flag to bypass document validation during the operation (default: false)

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 many[T](documents: Iterable[T])(implicit ec: ExecutionContext, writer: Writer[T]): Future[MultiBulkWriteResult]

Inserts many documents, according the ordered behaviour.

Inserts many documents, according the ordered behaviour.

import scala.concurrent.ExecutionContext.Implicits.global

import reactivemongo.api.bson.BSONDocument
import reactivemongo.api.bson.collection.BSONCollection

def insertMany(coll: BSONCollection, docs: Iterable[BSONDocument]) = {
 val insert = coll.insert(ordered = true)

 insert.many(docs) // Future[MultiBulkWriteResult]
}

Attributes

final def one[T](document: T)(implicit ec: ExecutionContext, writer: Writer[T]): Future[WriteResult]

Inserts a single document.

Inserts a single document.

import scala.concurrent.ExecutionContext.Implicits.global

import reactivemongo.api.bson.BSONDocument
import reactivemongo.api.bson.collection.BSONCollection

def insertOne(coll: BSONCollection, doc: BSONDocument) = {
 val insert = coll.insert(ordered = true)

 insert.one(doc)
}

Attributes