Skip to content

Kotlin BSON • Multiplatform abstraction for different BSON implementationsopensavvy.ktmongo.bsonBson

Bson

interface Bson

A BSON document.

To create instances of this class, see BsonFactory.

Implementation constraints

equals and hashCode should follow the same constraints as BsonDocumentReader's implementations.

Functions

at

infix inline fun <T> Bson.at(path: BsonPath): T

Finds the first value that matches path in a given BSON document.

diff

infix fun Bson.diff(other: Bson): String?

Analyzes the difference between two BSON documents.

read

inline fun <T : Any> Bson.read(): T?

Reads this document into an instance of type T.

reader

@LowLevelApi
abstract fun reader(): BsonDocumentReader

Reads the fields of this document.

select

inline fun <T> Bson.select(@Language
(value = "JSONPath") path: String): Sequence<T>

Finds all values that match path in a given BSON document.

inline fun <T> Bson.select(path: BsonPath): Sequence<T>

Finds all values that match path in a given BSON document.

selectFirst

inline fun <T> Bson.selectFirst(@Language
(value = "JSONPath") path: String): T

Finds the first value that matches path in a given BSON document.

inline fun <T> Bson.selectFirst(path: BsonPath): T

Finds the first value that matches path in a given BSON document.

toByteArray

@LowLevelApi
abstract fun toByteArray(): ByteArray

Low-level byte representation of this BSON document.

toString

abstract override fun toString(): String

JSON representation of this Bson object, as a String.