I have a document collection like:
{ "_id":"ABC", "job": {...} }
How to read a batch of Jobs given a collection of IDs from Mongo DB in Kotlin?
We search like this:
MongoClients.create(clientSettings).use { client ->
val db = client.getDatabase(dbName)
val coll = db.getCollection(collName)
val filter = Filters.`in`("_id", jobs.ids)
val res = coll.find(filter).map{ it.get("job") /* ??? */ }.asIterable()
return JobBatch(res)
}
Please see /* ??? */ - How to convert Document to Job class?