Package-level declarations

Utilities and primitives to read and write BSON documents.

opensavvy.ktmongo.bson.Bson and BsonArray respectively represent BSON documents and arrays.

BsonFactory is the entry point to create new BSON documents.

BsonPath provides a convenient way to search for data in a complex BSON document.

Types

Link copied to clipboard
sealed interface AnyBsonWriter

Parent interface for type parameters that can accept either BsonValueWriter or BsonFieldWriter.

Link copied to clipboard

A BSON array.

Link copied to clipboard

Exception thrown when decoding a BsonValue fails.

Link copied to clipboard

A BSON document.

Link copied to clipboard

Exception thrown when encoding a BsonValue fails.

Link copied to clipboard
interface BsonFactory

Entrypoint for creating BsonDocument and BsonArray instances.

Link copied to clipboard

An object that can be represented as fields in a BSON document.

Link copied to clipboard

Generator of BSON document fields.

Link copied to clipboard
sealed interface BsonPath

Access specific fields in arbitrary BSON documents using a JSONPath-like API.

Link copied to clipboard

The different data types supported in BSON documents.

Link copied to clipboard

An arbitrary BSON value.

Link copied to clipboard

An object that can be represented as a BSON value (value of a field, item in an array, an array itself).

Link copied to clipboard

Generator of BSON values.

Link copied to clipboard
annotation class BsonWriterDsl

Annotation to mark types that are part of the BSON writer DSL.

Link copied to clipboard
@RequiresOptIn(message = "This method is part of an experimental API to analyse the difference between BSON objects. Please share your feedback in https://gitlab.com/opensavvy/ktmongo/-/issues/98")
annotation class ExperimentalBsonDiffApi
Link copied to clipboard
@RequiresOptIn(message = "This symbol is part of the experimental BsonPath API. It may change or be removed without warnings. Please provide feedback in https://gitlab.com/opensavvy/ktmongo/-/issues/93.")
annotation class ExperimentalBsonPathApi

Properties

Link copied to clipboard

Deprecation messages for BSON functionality that is deprecated in the BSON spec.

Functions

Link copied to clipboard
infix inline fun <T> BsonDocument.at(path: BsonPath): T

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

Link copied to clipboard
fun BsonPath(@Language(value = "JSONPath") text: String): BsonPath

Parses an RFC-9535 compliant string expression into a BsonPath instance.

Link copied to clipboard
inline fun <T> BsonArray.decode(): T

Decodes this array into an instance of the Kotlin type T.

inline fun <T> BsonDocument.decode(): T

Decodes this document into an instance of the Kotlin type T.

inline fun <T> BsonValue.decode(): T

Decodes this value into an instance of the Kotlin type T.

Link copied to clipboard
inline fun <T> BsonArray.decodeElements(): List<T>

Decodes this array into a List of the Kotlin type T.

Link copied to clipboard
infix fun BsonArray.diff(other: BsonArray): String?

Analyzes the difference between two BSON arrays.

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

Analyzes the difference between two BSON documents.

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

Analyzes the difference between two BSON values.

Link copied to clipboard
inline fun <T : Any> BsonFactory.encode(obj: T): BsonDocument

Writes an arbitrary Kotlin obj into a top-level BSON document.

Link copied to clipboard
inline fun <T> BsonDocument.select(@Language(value = "JSONPath") path: String): Sequence<T>
inline fun <T> BsonDocument.select(path: BsonPath): Sequence<T>

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

Link copied to clipboard
inline fun <T> BsonDocument.selectFirst(@Language(value = "JSONPath") path: String): T
inline fun <T> BsonDocument.selectFirst(path: BsonPath): T

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