I have an object like below
class Test1 {
@Id
var id: ObjectId = _
@Reference
var referrenced: Referrenced = _
...
}
And referenced object
Class Referenced {
@Id
var id: ObjectId = _
var when: Date = _
}
How can I find all Test1
object that has Referenced
object when
between times?
You can use
$lookup
if you're doing an aggregation MongoDB 3.4. Otherwise, Mongo's query language doesn't support a join so you'd have to first query for all the ID values forReferenced
instances between those times and then query forTest1
instances with those ID values.