Skip to content

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

BsonValueWriter

@LowLevelApi
interface BsonValueWriter : AnyBsonWriter

Generator of BSON values.

This interface is used to write a generic BSON value. For example, the root BSON value, or a specific value of a field.

To write fields in a BSON document, see BsonFieldWriter.

Instances of this interface are commonly obtained by calling the BsonContext.buildArray function.

Functions

pipe

@LowLevelApi
@DangerousMongoApi
open fun pipe(obj: BsonValueReader)

Writes the arbitrary obj into this writer.

writeArray

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

writeBinaryData

@LowLevelApi
abstract fun writeBinaryData(type: UByte, data: ByteArray)

writeBoolean

@LowLevelApi
abstract fun writeBoolean(value: Boolean)

writeDateTime

@LowLevelApi
abstract fun writeDateTime(value: Long)

writeDBPointer

@LowLevelApi
abstract fun writeDBPointer(namespace: String, id: ByteArray)

writeDecimal128

@LowLevelApi
abstract fun writeDecimal128(low: Long, high: Long)

writeDocument

@LowLevelApi
abstract fun writeDocument(block: BsonFieldWriter.() -> Unit)

writeDouble

@LowLevelApi
abstract fun writeDouble(value: Double)

writeInstant

@ExperimentalTime
@LowLevelApi
open fun writeInstant(value: Instant)

Writes an Instant. Conversion function on top of writeDateTime.

writeInt32

@LowLevelApi
open fun writeInt32(value: Byte)
@LowLevelApi
abstract fun writeInt32(value: Int)
@LowLevelApi
open fun writeInt32(value: Short)

writeInt64

@LowLevelApi
abstract fun writeInt64(value: Long)

writeJavaScript

@LowLevelApi
abstract fun writeJavaScript(code: String)

writeJavaScriptWithScope

@LowLevelApi
abstract fun writeJavaScriptWithScope(code: String)

writeMaxKey

@LowLevelApi
abstract fun writeMaxKey()

writeMinKey

@LowLevelApi
abstract fun writeMinKey()

writeNull

@LowLevelApi
abstract fun writeNull()

writeObjectId

@LowLevelApi
abstract fun writeObjectId(id: ByteArray)

writeObjectSafe

@LowLevelApi
abstract fun <T> writeObjectSafe(obj: T)

Writes an arbitrary obj into a BSON document.

writeRegularExpression

@LowLevelApi
abstract fun writeRegularExpression(pattern: String, options: String)

writeString

@LowLevelApi
abstract fun writeString(value: String)

writeSymbol

@LowLevelApi
abstract fun writeSymbol(value: String)

writeTimestamp

@LowLevelApi
abstract fun writeTimestamp(value: Timestamp)

writeUndefined

@LowLevelApi
abstract fun writeUndefined()