Kotlin BSON • Multiplatform abstraction for different BSON implementations • opensavvy.ktmongo.bson • BsonDocumentReader
BsonDocumentReader¶
@LowLevelApi
interface BsonDocumentReader
Utilities for decomposing a Bson document into its fields.
To obtain an instance of this interface, see Bson.reader.
Example¶
val bson: Bson = …
for ((name, field) in bson.read().entries) {
println("Field: $name • ${field.type}")
}
Implementation constraints¶
Different implementations of BsonDocumentReader should be considered equal if they have the same fields which each have the same values. The methods BsonDocumentReader.Companion.equals and BsonDocumentReader.Companion.hashCode are provided to facilitate implementation.
Types¶
Companion¶
object Companion
Properties¶
entries¶
abstract val entries: Map<String, BsonValueReader>
A map allowing to go through all key-value pairs in the document.
names¶
A set of the field names in the document.
Functions¶
asValue¶
abstract fun asValue(): BsonValueReader
Reads this entire document as a BsonValueReader.
diff¶
@LowLevelApi
infix fun BsonDocumentReader.diff(other: BsonDocumentReader): String?
Analyzes the difference between two BSON documents.
read¶
abstract fun read(name: String): BsonValueReader?
Attempts to read a field named name.
Reads this document into an instance of type.
toBson¶
Reads this document into a Bson instance.
toString¶
JSON representation of the document this BsonDocumentReader is reading, as a String.