MongoDatabase¶
interface MongoDatabase
A single MongoDB instance can store multiple databases.
Each database has a unique name and isolates applications to avoid name collisions even if two applications use the same MongoCollection name.
To obtain a database, see MongoClient.database.
To obtain a collection, see collection.
Properties¶
client¶
abstract val client: MongoClient
The MongoClient which created this database.
The MongoClient instance is responsible for the global configuration.
name¶
Functions¶
collection¶
@LowLevelApi
abstract fun <Document : Any> collection(name: String, type: KType): MongoCollection<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.
Prefer using the overload that doesn't have a type argument. If type is specified, it must match Document. Otherwise, the behavior is unspecified.
inline fun <Document : Any> collection(name: String): MongoCollection<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.