Skip to content

Kotlin BSON • Multiplatform abstraction for different BSON implementationsopensavvy.ktmongo.bsonBsonContext

BsonContext

Configuration for the BSON serialization.

Instances of this class are platform-specific and are used to create BSON documents. Platforms can thus parameterize the behavior of writers and readers.

For example, a platform may store its serialization configuration in this class.

Functions

buildArray

@LowLevelApi
abstract fun buildArray(block: BsonValueWriter.() -> Unit): BsonArray

Instantiates a new BSON array.

@LowLevelApi
open fun buildArray(instance: BsonValueWriteable): BsonArray

Instantiates a new BSON array representing the provided instance.

buildDocument

@LowLevelApi
abstract fun buildDocument(block: BsonFieldWriter.() -> Unit): Bson

Instantiates a new BSON document.

@LowLevelApi
open fun buildDocument(instance: BsonFieldWriteable): Bson

Instantiates a new BSON document representing the provided instance.

newId

@ExperimentalTime
abstract fun newId(): ObjectId

Creates a new instance of an ObjectId.

readArray

@LowLevelApi
abstract fun readArray(bytes: ByteArray): BsonArray

Instantiates a new BSON array by reading its bytes representation.

readDocument

@LowLevelApi
abstract fun readDocument(bytes: ByteArray): Bson

Instantiates a new BSON document by reading its bytes representation.