write

inline fun <T : Any> BsonContext.write(obj: T): Bson(source)

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

A top-level BSON document cannot be null, cannot be a primitive, and cannot be a collection. If obj is not representable as a document, an exception is thrown.

See also

The inverse operation.