SyncMongoDatabase¶
interface SyncMongoDatabase : MongoDatabase
A grouping of collections with the same theme.
The Coroutine client provides a coroutine-aware API which internally uses the official Kotlin driver.
What is a database?¶
MongoCollection are grouped into databases to avoid name collisions. Databases are similar to Kotlin packages. If multiple applications are deployed in the same MongoDB instance in their own database, they can use the same collection names (e.g. users) without conflicts.
Each database has a name that must be unique within a MongoDB deployment.
Access¶
To obtain a database, see MongoClient.database.
To obtain a collection, see collection.
External resources¶
See also¶
- asKtMongoLegacy: Convert an existing instance from the official Kotlin driver.
Properties¶
name¶
Functions¶
asOfficial¶
abstract fun asOfficial(): MongoDatabase
Obtains the underlying MongoDB database from the official Kotlin driver.
collection¶
@LowLevelApi
abstract override fun <Document : Any> collection(name: String, type: KType): SyncMongoCollection<Document>
inline fun <Document : Any> collection(name: String): SyncMongoCollection<Document>
Creates a MongoCollection object.
This method is purely a client-side operation, it does nothing in the MongoDB server. In MongoDB, databases and collections are created implicitly on the first insert.
For an example, see MongoClient.