Kotlin BSON • Multiplatform abstraction for different BSON implementations • opensavvy.ktmongo.bson • BsonContext • buildDocument
buildDocument¶
@LowLevelApi
abstract fun buildDocument(block: BsonFieldWriter.() -> Unit): Bson
@LowLevelApi
open fun buildDocument(instance: BsonFieldWriteable): Bson
Instantiates a new BSON document representing the provided instance.
Writes an arbitrary Kotlin obj into a top-level BSON document.
Prefer using BsonContext.write.
A top-level BSON document cannot be null, cannot be a primitive, and cannot be a collection. If obj is not representable as a document, an exception is thrown.