CoroutineMongoCollection
A collection stores related documents together.
The Coroutine client provides a coroutine-aware API which internally uses the official Kotlin driver.
Usually, all documents in a collection have the same shape (the same fields). However, heterogeneous structure can be achieved by using:
Kotlin collections, like List and Set, the embed an arbitrary number of items.
Polymorphism, for example with
sealed class, to have different fields based on a discriminator.
To avoid name collisions, collections are grouped into databases.
To obtain a collection, see MongoDatabase.collection.
Size limit
A MongoDB document cannot exceed 16 MiB.
You can measure the size of a document with opensavvy.ktmongo.bson.BsonDocument.toByteArray followed by ByteArray.size.
The maximum nesting is 100 levels. Each document or array adds a level.
External resources
See also
Convert an existing instance from the official Kotlin driver.
Types
The return value of upsertOne and upsertOneWithPipeline.
Properties
Functions
Obtains the underlying MongoDB collection from the official Kotlin driver.