BsonDocumentExtensions

molly.core.syntax.BsonDocumentExtensions
final class BsonDocumentExtensions(bsonDoc: BsonDocument)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def append(key: String, valueOpt: Option[BsonValue]): BsonDocument

Append an optional value with the given key to the document.

Append an optional value with the given key to the document.

Value parameters

key

The key field

valueOpt

An Option BsonValue(@see org.bson.BsonValue), only if the value is defined then the key value pair will be inserted into the BsonDocument

Attributes

Returns

this BsonDocument

def getOption[T <: BsonValue : ClassTag](key: String): Option[T]

Read the value from the BsonDocument using the key. If the key does not exist or the type of the value is not as expected, None will be returned

Read the value from the BsonDocument using the key. If the key does not exist or the type of the value is not as expected, None will be returned

Type parameters

T

the type parameter for the expected value

Value parameters

key

The key field

Attributes

Returns

optional value of type T

def setOption(key: String, value: Option[BsonValue]): BsonDocument

If the value is not None, the key value pair will be inserted into the BsonDocument. If the value is None, then the key field is going to be removed from the BsonDocument

If the value is not None, the key value pair will be inserted into the BsonDocument. If the value is None, then the key field is going to be removed from the BsonDocument

Value parameters

key

The key field

value

An Option BsonValue(@see org.bson.BsonValue)

Attributes

Returns

this BsonDocument