JvmBsonFactory¶
interface JvmBsonFactory : BsonFactory
BSON implementation based on the official Java and Kotlin MongoDB drivers.
Constructors¶
JvmBsonFactory¶
fun JvmBsonFactory(codecRegistry: CodecRegistry): JvmBsonFactory
Instantiates a new BsonFactory that respects the configuration in the specified codecRegistry.
Objects created by this factory internally use the official BSON Java library.
Note that the JvmBsonFactory.codecRegistry attribute may be different from the passed codecRegistry. In particular, this function adds new codecs for KtMongo-specific types. If mixing KtMongo with the official driver, we recommend configuring the official driver with the JvmBsonFactory.codecRegistry generated by this function. Otherwise, the official driver may serialize KtMongo types differently.
Properties¶
codecRegistry¶
@LowLevelApi
abstract val codecRegistry: CodecRegistry
The codec registry used by this factory to create new documents.
This registry includes codecs for KtMongo-specific types. When mixing KtMongo with the official driver, it is recommended to configure the official driver using this registry to ensure types are serialized identically by both libraries.
Functions¶
buildArray¶
@LowLevelApi
abstract override fun buildArray(block: BsonValueWriter.() -> Unit): BsonArray
@LowLevelApi
open override fun buildArray(instance: BsonValueWriteable): BsonArray
buildDocument¶
@LowLevelApi
abstract override fun buildDocument(block: BsonFieldWriter.() -> Unit): Bson
@LowLevelApi
open override fun buildDocument(instance: BsonFieldWriteable): Bson
readArray¶
Instantiates a new BsonArray instance by wrapping the official driver's BsonArray.
The opposite operation is opensavvy.ktmongo.bson.official.BsonArray.raw.
readDocument¶
@LowLevelApi
abstract override fun readDocument(bytes: ByteArray): Bson
@LowLevelApi
open fun readDocument(value: BsonDocument): Bson
Instantiates a new Bson instance by wrapping the official driver's BsonDocument.
The opposite operation is Bson.raw.
readValue¶
@LowLevelApi
open fun readValue(value: BsonValue): BsonValueReader
Instantiates a new BsonValueReader instance by wrapping the official driver's BsonValue.