Skip to content

BsonContext

BSON configuration for the objects generated by the DSL.

This object is passed through the entire DSL to allow accessing the configuration from anywhere during request generation.

Constructors

BsonContext

@ExperimentalAtomicApi
fun BsonContext(
    bsonFactory: BsonFactory, 
    objectIdGenerator: ObjectIdGenerator = ObjectIdGenerator.Default(), 
    nameStrategy: PropertyNameStrategy = PropertyNameStrategy.Default
): BsonContext

BSON configuration for the objects generated by the DSL.

Functions

buildArray

@LowLevelApi
abstract fun buildArray(block: BsonValueWriter.() -> Unit): BsonArray

buildDocument

encode

@LowLevelApi
abstract fun <T : Any> encode(obj: T, type: KType): BsonDocument

newId

abstract fun newId(): ObjectId

pathOf

@LowLevelApi
abstract fun pathOf(property: KProperty1<*, *>): Path

Generates the name of a property.

readArray

@LowLevelApi
abstract fun readArray(bytes: ByteArray): BsonArray
open fun readArray(array: BsonArray): BsonArray

readDocument

open fun readDocument(document: BsonDocument): BsonDocument

readValue

open fun readValue(value: BsonValue): BsonValue