KongoService
A service for abstracting MongoDB internals.
Example:
data class Foo(
@SerialName("_id") val id: DocumentId,
val bar: String
)
class FooService : KongoService<Foo> {
override val info by meta(name = "test")
override val database by inject() // provide instance however you want
suspend fun getFoo(bar: String): Result<Foo> = operation {
find { Foo::bar equals bar }.first()
}
}
Content copied to clipboard
Types
Properties
Functions
Link copied to clipboard
inline fun <T : Any> KongoService<T>.meta(name: String, options: CreateCollectionOptions = CreateCollectionOptions()): ReadOnlyProperty<Any?, KongoService.Info<T>>
Automatically configures KongoService.Info for your service.