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:

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

Link copied to clipboard
class Field(val name: String, val value: BsonValue) : BsonDocument.Field
Link copied to clipboard

Serializer for the multiplatform opensavvy.ktmongo.bson.multiplatform.BsonDocument implementation.

Properties

Link copied to clipboard
open override val factory: BsonFactory
Link copied to clipboard
open override val fields: Set<String>
Link copied to clipboard
open override val size: Int

Functions

Link copied to clipboard
open override fun asIterable(): Iterable<BsonDocument.Field>
Link copied to clipboard
open override fun asMap(): Map<String, BsonValue>
Link copied to clipboard
open override fun asSequence(): Sequence<BsonDocument.Field>
Link copied to clipboard
open override fun asValue(): BsonValue
Link copied to clipboard
open override fun <T> decode(type: KType): T
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open operator override fun get(field: String): BsonValue?
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open fun isNotEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Iterator<BsonDocument.Field>
Link copied to clipboard
open override fun toByteArray(): ByteArray
Link copied to clipboard
open override fun toString(): String