Marcus Fihlon
04/15/2017, 7:22 PMimport com.mongodb.client.MongoCollection
import org.litote.kmongo.KMongo
import org.litote.kmongo.getCollection
import kotlin.reflect.KClass
object PersistenceManager {
fun <T : Any> createCollection(clazz: KClass<T>): MongoCollection<T> {
val client = KMongo.createClient()
val database = client.getDatabase("test")
val collection = database.getCollection<clazz>()
return collection
}
}
The parameter clazz is shown as unused and the compiler complains Unresolved reference: clazz in the line val collection = database.getCollection<clazz>(). I don’t understand why. Can someone explain it to me and point me into the direction of a correct implementation, please?