Something went wrong. Try again.
The next MongoDB driver for Kotlin ktmongo.opensavvy.dev
kotlin mongodb multiplatform
Something went wrong. Try again.
ktmongo driver-sync
1 folder · 3 files
README.md
Module KtMongo: MongoDB driver for Kotlin • Synchronous #
Blocking/synchronous driver for MongoDB, using a rich Kotlin DSL.
Configuration #
Add a dependency on dev.opensavvy.ktmongo:driver-sync.
For example, in a Kotlin Multiplatform project:
plugins {
kotlin("multiplatform")
}
kotlin {
jvm()
// …
sourceSets.commonMain.dependencies {
implementation("dev.opensavvy.ktmongo:driver-sync:VERSION-HERE")
}
}
In a Kotlin JVM project:
plugins {
kotlin("jvm")
}
dependencies {
implementation("dev.opensavvy.ktmongo:driver-sync:VERSION-HERE")
}
Basic usage #
Once you have obtained an instance of [MongoCollection][opensavvy.ktmongo.sync.MongoCollection] (see platform-specific instructions on how to do this), you can use it to access the database:
class User(
val _id: ObjectId,
val name: String,
val age: Int,
)
collection.findOne {
User::age gte 18
}
collection.update(
filter = {
User::_id eq ObjectId("507f1f77bcf86cd799439011")
},
update = {
User::name set "Bob"
}
)
[Learn more about the available operations][opensavvy.ktmongo.sync.MongoCollection].
Package opensavvy.ktmongo.sync #
Declaration and implementation of collections and iterables.
Package opensavvy.ktmongo.sync.operations #
Declaration of the different types of operations.