I have the following object:
How can I search for it by only the startDate and endDate fields in the content sub-json?
I tried:
collection.findOne(content: [startDate : givenStartDate, endDate : givenEndDate])
But I guess this would return it only if the entry would have these specific dates but no evalDate, am I right?
How can I query just based on startDate and endDate?
Thanks!
Try like below. You need to use dot operator for sub documents.
collection.findOne("content.startDate" : givenStartDate, "content.endDate" : givenEndDate)