BsonValue
An arbitrary BSON value.
The BSON specification only allows root documents, so it is not possible to instantiate this interface directly with a complex structure. This interface is used to decode the fields of a BsonDocument or the items of a BsonArray.
To instantiate a BsonDocument or BsonArray, see BsonFactory.
Navigating BSON types
This interface is part of the BSON trinity:
BsonDocument represents an entire BSON document.
BsonArray represents an array of BSON values.
BsonValue represents a single value in isolation.
Usage
If this BSON value is the serialized form of a Kotlin DTO, see decode.
This interface provides methods for decoding the different BSON native types, like decodeInt32, decodeObjectId and decodeInstant.
Some BSON types cannot be represented by a single Kotlin type, so multiple methods are provided to decode their components. For example: decodeRegularExpressionPattern and decodeRegularExpressionOptions.
Equality
Different implementations of this interface are considered equal if they represent the same value with the same type. That is, both values would result in the exact same BSON sent over the wire.
The methods BsonValue.Companion.equals and BsonValue.Companion.hashCode are provided as default implementations.
Properties
Functions
Decodes this value as a nested BsonArray.
Decodes a binary blob.
Decodes the type of a binary blob.
Decodes this value as a Boolean.
Decodes this value as a UTC timestamp in milliseconds since the Unix epoch.
Decodes this value as the ID of a database pointer.
Decodes this value as the namespace of a database pointer.
Decodes this value as the bytes of a Decimal128.
Decodes this value as a nested BsonDocument.
Decodes this value as Double.
Decodes this value as a Kotlin Instant.
Decodes this value as Int.
Decodes this value as Long.
Decodes this value as JavaScript code.
Decodes this value as a document describing variables some JavaScript code has access to.
Decodes the special BSON value BsonType.MaxKey.
Decodes the special BSON value BsonType.MinKey.
Decodes this value as a Kotlin null.
Decodes this value as a ObjectId.
Decodes this value as the bytes of an ObjectId.
Decodes this value as the options of a regular expression.
Decodes this value as the pattern of a regular expression.
Decodes this value as a string.
Decodes this value as a symbol.
Decodes this value as a Timestamp.
Decodes this value as an undefined value.
Decodes a binary Vector.
Returns this value, unless it is undefined or null, in which case returns null.