from
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
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