jvmMain.MongoKeyValueStoreFactory.kt Maven / Gradle / Ivy
The newest version!
package io.fluidsonic.raptor.keyvaluestore.mongo
import io.fluidsonic.mongo.*
import io.fluidsonic.raptor.keyvaluestore.*
import kotlin.reflect.*
private class MongoKeyValueStoreFactory(
private val database: MongoDatabase,
) : RaptorKeyValueStoreFactory {
override fun create(name: String, keyClass: KClass, valueClass: KClass): RaptorKeyValueStore =
MongoKeyValueStore(
collection = database.getCollectionOf(name),
keyClass = keyClass,
valueClass = valueClass,
)
}
public fun RaptorKeyValueStoreFactory.Companion.mongo(database: MongoDatabase): RaptorKeyValueStoreFactory =
MongoKeyValueStoreFactory(database = database)