BsonDocument

class BsonDocument(initial: Map<String, BsonValue>) : BsonValue, MutableMap<String, BsonValue>

A type-safe container for a BSON document.

Parameters

initial

the initial values

Constructors

Link copied to clipboard
fun BsonDocument(initialCapacity: Int)

Construct an empty document with the specified initial capacity.

Link copied to clipboard
fun BsonDocument(key: String, value: BsonValue)

Construct a new instance with a single key value pair

Link copied to clipboard
fun BsonDocument(bsonElements: List<BsonElement>)

Construct a new instance with the given list BsonElements

Link copied to clipboard
fun BsonDocument(vararg pairs: Pair<String, BsonValue>)

Construct a new instance with the varargs of key value pairs

Link copied to clipboard
fun BsonDocument(initial: Map<String, BsonValue> = LinkedHashMap())

constructs the bson document with the initial values, defaults to an empty document

Types

Link copied to clipboard
object Companion

BsonDocument companion object

Functions

Link copied to clipboard
fun append(key: String, value: BsonValue): BsonDocument

Put the given key and value into this document, and return the document.

Link copied to clipboard
fun asArray(): BsonArray

Gets this value as a BsonArray if it is one, otherwise throws exception

Link copied to clipboard
fun asBinary(): BsonBinary

Gets this value as a BsonBinary if it is one, otherwise throws exception

Link copied to clipboard
fun asBoolean(): BsonBoolean

Gets this value as a BsonBoolean if it is one, otherwise throws exception

Link copied to clipboard
fun asBsonMaxKey(): BsonMaxKey

Gets this value as a BsonMaxKey if it is one, otherwise throws exception

Link copied to clipboard
fun asBsonMinKey(): BsonMinKey

Gets this value as a BsonMinKey if it is one, otherwise throws exception

Link copied to clipboard
fun asBsonNull(): BsonNull

Gets this value as a BsonNull if it is one, otherwise throws exception

Link copied to clipboard
fun asBsonUndefined(): BsonUndefined

Gets this value as a BsonUndefined if it is one, otherwise throws exception

Link copied to clipboard
fun asDateTime(): BsonDateTime

Gets this value as a BsonDateTime if it is one, otherwise throws exception

Link copied to clipboard
fun asDBPointer(): BsonDBPointer

Gets this value as a BsonDBPointer if it is one, otherwise throws exception

Link copied to clipboard
fun asDecimal128(): BsonDecimal128

Gets this value as a BsonDecimal128 if it is one, otherwise throws exception

Link copied to clipboard
fun asDocument(): BsonDocument

Gets this value as a BsonDocument if it is one, otherwise throws exception

Link copied to clipboard
fun asDouble(): BsonDouble

Gets this value as a BsonDouble if it is one, otherwise throws exception

Link copied to clipboard
fun asInt32(): BsonInt32

Gets this value as a BsonInt32 if it is one, otherwise throws exception

Link copied to clipboard
fun asInt64(): BsonInt64

Gets this value as a BsonInt64 if it is one, otherwise throws exception

Link copied to clipboard
fun asJavaScript(): BsonJavaScript

Gets this value as a BsonJavaScript if it is one, otherwise throws exception

Link copied to clipboard
fun asJavaScriptWithScope(): BsonJavaScriptWithScope

Gets this value as a BsonJavaScriptWithScope if it is one, otherwise throws exception

Link copied to clipboard
fun asNumber(): BsonNumber

Gets this value as a BsonNumber if it is one, otherwise throws exception

Link copied to clipboard
fun asObjectId(): BsonObjectId

Gets this value as an BsonObjectId if it is one, otherwise throws exception

Link copied to clipboard
fun asRegularExpression(): BsonRegularExpression

Gets this value as a BsonRegularExpression if it is one, otherwise throws exception

Link copied to clipboard
fun asString(): BsonString

Gets this value as a BsonString if it is one, otherwise throws exception

Link copied to clipboard
fun asSymbol(): BsonSymbol

Gets this value as a BsonSymbol if it is one, otherwise throws exception

Link copied to clipboard
fun asTimestamp(): BsonTimestamp

Gets this value as a BsonTimestamp if it is one, otherwise throws exception

Link copied to clipboard
open override fun clear()
Link copied to clipboard
fun clone(): BsonDocument

Clone the document

Link copied to clipboard
open override fun containsKey(key: String): Boolean
Link copied to clipboard
open override fun containsValue(value: BsonValue): Boolean
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open operator override fun get(key: String): BsonValue?

operator fun get(key: String, defaultValue: BsonValue): BsonValue

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key.

Link copied to clipboard
fun getArray(key: String): BsonArray

Gets the value of the key if it is a BsonArray, or throws if not.

fun getArray(key: String, defaultValue: BsonArray): BsonArray

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonArray.

Link copied to clipboard
fun getBinary(key: String): BsonBinary

Gets the value of the key if it is a BsonBinary, or throws if not.

fun getBinary(key: String, defaultValue: BsonBinary): BsonBinary

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonBinary.

Link copied to clipboard
fun getBoolean(key: String): BsonBoolean

Gets the value of the key if it is a BsonBoolean, or throws if not.

fun getBoolean(key: String, defaultValue: BsonBoolean): BsonBoolean

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonBoolean.

Link copied to clipboard
fun getDateTime(key: String): BsonDateTime

Gets the value of the key if it is a BsonDateTime, or throws if not.

fun getDateTime(key: String, defaultValue: BsonDateTime): BsonDateTime

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDateTime.

Link copied to clipboard
fun getDecimal128(key: String): BsonDecimal128

Gets the value of the key if it is a BsonDecimal128, or throws if not.

fun getDecimal128(key: String, defaultValue: BsonDecimal128): BsonDecimal128

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDecimal128.

Link copied to clipboard
fun getDocument(key: String): BsonDocument

Gets the value of the key if it is a BsonDocument, or throws if not.

fun getDocument(key: String, defaultValue: BsonDocument): BsonDocument

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDocument.

Link copied to clipboard
fun getDouble(key: String): BsonDouble

Gets the value of the key if it is a BsonDouble, or throws if not.

fun getDouble(key: String, defaultValue: BsonDouble): BsonDouble

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonDouble.

Link copied to clipboard
fun getFirstKey(): String

Gets the first key in the document.

Link copied to clipboard
fun getInt32(key: String): BsonInt32

Gets the value of the key if it is a BsonInt32, or throws if not.

fun getInt32(key: String, defaultValue: BsonInt32): BsonInt32

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonInt32.

Link copied to clipboard
fun getInt64(key: String): BsonInt64

Gets the value of the key if it is a BsonInt64, or throws if not.

fun getInt64(key: String, defaultValue: BsonInt64): BsonInt64

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonInt64.

Link copied to clipboard
fun getNumber(key: String): BsonNumber

Gets the value of the key if it is a BsonNumber, or throws if not.

fun getNumber(key: String, defaultValue: BsonNumber): BsonNumber

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonNumber.

Link copied to clipboard
fun getObjectId(key: String): BsonObjectId

Gets the value of the key if it is a BsonObjectId, or throws if not.

fun getObjectId(key: String, defaultValue: BsonObjectId): BsonObjectId

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonObjectId.

Link copied to clipboard
fun getRegularExpression(key: String): BsonRegularExpression

Gets the value of the key if it is a BsonRegularExpression, or throws if not.

fun getRegularExpression(key: String, defaultValue: BsonRegularExpression): BsonRegularExpression

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonRegularExpression.

Link copied to clipboard
fun getString(key: String): BsonString

Gets the value of the key if it is a BsonString, or throws if not.

fun getString(key: String, defaultValue: BsonString): BsonString

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonString.

Link copied to clipboard
fun getTimestamp(key: String): BsonTimestamp

Gets the value of the key if it is a BsonTimestamp, or throws if not.

fun getTimestamp(key: String, defaultValue: BsonTimestamp): BsonTimestamp

If the document does not contain the given key, return the given default value. Otherwise, gets the value of the key as a BsonTimestamp.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun isArray(): Boolean

fun isArray(key: String): Boolean

Returns true if the value of the key is a BsonArray, returns false if the document does not contain the key.

Link copied to clipboard
fun isBinary(): Boolean

fun isBinary(key: String): Boolean

Returns true if the value of the key is a BsonBinary, returns false if the document does not contain the key.

Link copied to clipboard
fun isBoolean(): Boolean

fun isBoolean(key: String): Boolean

Returns true if the value of the key is a BsonBoolean, returns false if the document does not contain the key.

Link copied to clipboard
fun isDateTime(): Boolean

fun isDateTime(key: String): Boolean

Returns true if the value of the key is a BsonDateTime, returns false if the document does not contain the key.

Link copied to clipboard
fun isDBPointer(): Boolean
Link copied to clipboard
fun isDecimal128(): Boolean

fun isDecimal128(key: String): Boolean

Returns true if the value of the key is a BsonDecimal128, returns false if the document does not contain the key.

Link copied to clipboard
fun isDocument(): Boolean

fun isDocument(key: String): Boolean

Returns true if the value of the key is a BsonDocument, returns false if the document does not contain the key.

Link copied to clipboard
fun isDouble(): Boolean

fun isDouble(key: String): Boolean

Returns true if the value of the key is a BsonDouble, returns false if the document does not contain the key.

Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
fun isInt32(): Boolean

fun isInt32(key: String): Boolean

Returns true if the value of the key is a BsonInt32, returns false if the document does not contain the key.

Link copied to clipboard
fun isInt64(): Boolean

fun isInt64(key: String): Boolean

Returns true if the value of the key is a BsonInt64, returns false if the document does not contain the key.

Link copied to clipboard
fun isJavaScript(): Boolean
Link copied to clipboard
fun isJavaScriptWithScope(): Boolean
Link copied to clipboard
fun isMaxKey(): Boolean
Link copied to clipboard
fun isMinKey(): Boolean
Link copied to clipboard
fun isNull(): Boolean

fun isNull(key: String): Boolean

Returns true if the value of the key is a BsonNull, returns false if the document does not contain the key.

Link copied to clipboard
fun isNumber(): Boolean

fun isNumber(key: String): Boolean

Returns true if the value of the key is a BsonNumber, returns false if the document does not contain the key.

Link copied to clipboard
fun isObjectId(): Boolean

fun isObjectId(key: String): Boolean

Returns true if the value of the key is a BsonObjectId, returns false if the document does not contain the key.

Link copied to clipboard
fun isRegularExpression(): Boolean
Link copied to clipboard
fun isString(): Boolean

fun isString(key: String): Boolean

Returns true if the value of the key is a BsonString, returns false if the document does not contain the key.

Link copied to clipboard
fun isSymbol(): Boolean
Link copied to clipboard
fun isTimestamp(): Boolean

fun isTimestamp(key: String): Boolean

Returns true if the value of the key is a BsonTimestamp, returns false if the document does not contain the key.

Link copied to clipboard
fun isUndefined(): Boolean
Link copied to clipboard
open override fun put(key: String, value: BsonValue): BsonValue?
Link copied to clipboard
open override fun putAll(from: Map<out String, BsonValue>)
Link copied to clipboard
open override fun remove(key: String): BsonValue?
Link copied to clipboard
fun toByteArray(): ByteArray

Returns the Bson bytes for this document

Link copied to clipboard
fun toJson(): String

Return an extended json representation of this BsonValue

Link copied to clipboard
open override fun toString(): String

Properties

Link copied to clipboard
open override val bsonType: BsonType

Gets the BSON type of this value.

Link copied to clipboard
open override val entries: MutableSet<MutableMap.MutableEntry<String, BsonValue>>
Link copied to clipboard
open override val keys: MutableSet<String>
Link copied to clipboard
open override val size: Int
Link copied to clipboard
open override val values: MutableCollection<BsonValue>