kmongo / org.litote.kmongo / com.mongodb.client.MongoDatabase

Extensions for com.mongodb.client.MongoDatabase

getCollection

Gets a collection.

fun <T : Any> MongoDatabase.getCollection(collectionName: String): MongoCollection<T>
fun <T : Any> MongoDatabase.getCollection(): MongoCollection<T>

getCollectionOfName

Gets a collection.

fun <T : Any> MongoDatabase.getCollectionOfName(collectionName: String): MongoCollection<T>

runCommand

Executes the given command in the context of the current database with the given read preference.

fun <TResult : Any> MongoDatabase.runCommand(command: String, readPreference: ReadPreference): TResult
fun <TResult : Any> MongoDatabase.runCommand(command: String): TResult
fun <TResult : Any> MongoDatabase.runCommand(clientSession: ClientSession, command: String, readPreference: ReadPreference): TResult
fun <TResult : Any> MongoDatabase.runCommand(clientSession: ClientSession, command: String): TResult

withKMongo

Returns a MongoDatabase with a KMongo codec.

fun MongoDatabase.withKMongo(): MongoDatabase