from
fun <T : Any> from(driver: MongoCollection<T>, documentType: KType, nameStrategy: PropertyNameStrategy = PropertyNameStrategy.Default): JvmMongoCollection<T>(source)
Converts a Java MongoDB collection into a KtMongo collection.
Example (Java)
try (var client = MongoClients.create()) {
var javaCollection = client.getDatabase("my-db")
.getCollection("my-col", MyCollection.class);
var collection = KtMongo.from(javaCollection);
System.out.println(
collection.find().toList()
);
}Content copied to clipboard
fun <T : Any> from(driver: MongoCollection<T>, documentType: KType, nameStrategy: PropertyNameStrategy = PropertyNameStrategy.Default): JvmMongoCollection<T>(source)
Converts a Kotlin MongoDB collection into a KtMongo collection.
Example (Kotlin)
MongoClients.create().use { client ->
val kotlinCollection = it.getDatabase("my-db")
.getCollection("my-col", MyCollection::class.java)
val collection = KtMongo.from(kotlinCollection)
println(
collection.find().toList()
)
}Content copied to clipboard