KMongo

object KMongo

Main object used to create a MongoClient instance of the official MongoDB Kotlin sync driver, configured with the KMongo object mapping.

Functions

Link copied to clipboard
fun createClient(): MongoClient

Creates a MongoClient instance with default connection string (localhost).

fun createClient(connectionString: ConnectionString): MongoClient
fun createClient(connectionString: String): MongoClient

Creates a MongoClient with the given connection string.

fun createClient(settings: MongoClientSettings): MongoClient

Creates a MongoClient with the given settings (the codec registry is updated with KMongo mapping).

fun createClient(javaClient: MongoClient): MongoClient

Wraps a Java sync driver client in a Kotlin sync driver client (they share the same connection pool, closing one closes the other).

Link copied to clipboard
fun createJavaClient(settings: MongoClientSettings): MongoClient

Creates a Java sync driver client (com.mongodb.client.MongoClient) with the given settings (the codec registry is updated with KMongo mapping).

fun createJavaClient(connectionString: String): MongoClient

Creates a Java sync driver client (com.mongodb.client.MongoClient) with the given connection string (see createJavaClient).