BsonDocument
Pure Kotlin implementation of opensavvy.ktmongo.bson.BsonDocument.
To create instances of this class, see BsonFactory.
This page describes the BSON multiplatform implementation. To learn more about the general BSON operations, see opensavvy.ktmongo.bson.BsonDocument.
Navigating BSON types
This class 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
val bson: BsonDocument = …
for ((name, field) in bson) {
println("Field: $name • ${field.type}")
}The iteration order of a BSON document is preserved: fields appear in the same order as they are written in.
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 BsonDocument.Companion.equals and BsonDocument.Companion.hashCode are provided as default implementations.
Thread-safety
This class is not thread-safe. Although it is not possible to mutate its state, this class uses internal mutation to lazily decode the BSON stream.
Types
Serializer for the multiplatform opensavvy.ktmongo.bson.multiplatform.BsonDocument implementation.