collection

abstract fun collection(collectionName: String): MongoCollection<BsonDocument>

Get a MongoCollection that exposed methods to retrieve and update data from the database's collection.

Serialization to and from EJSON is performed with KBSON and requires to opt-in to the experimental ExperimentalKBsonSerializerApi-feature.

Return

a MongoCollection that will accept and return entities from the remote collection as BsonDocument values.

Parameters

collectionName

the name of the collection name that the MongoCollection will connect to.


@ExperimentalKBsonSerializerApi
abstract fun <T> collection(collectionName: String, eJson: EJson? = null): MongoCollection<T>

Get a MongoCollection that exposed methods to retrieve and update data from the database's collection with specific typed serialization.

Serialization to and from EJSON is performed with KBSON and requires to opt-in to the experimental ExperimentalKBsonSerializerApi-feature.

Return

a MongoCollection that will accept and return entities from the remote collection as T values.

Parameters

collectionName

the name of the collection name that the MongoCollection will connect to.

eJson

the EJson serializer that the MongoCollection should use to convert objects and primary keys with. Will default to the databases EJson instance. For details on configuration of serialization see MongoClient.

T

the default type that remote entities of the collection will be serialized from and to.