I have a collection of documents that each contain an array of sub documents. Each subdocument has an time value. I am trying to see if I can return a sub document, based on the time in the sub document.
I know that I can retrieve a sub document using $slice, but $slice only give me a specific index or range and offset.
Example time!
Documents are like so....
{
id: 1234,
type: 'a',
subs: [
{ time: 123001, val: 'a' },
{ time: 123002, val: 'b' },
{ time: 123003, val: 'c' }
]
}
If I do a query with find({}, {subs: {$slice: [2,1]}}) I get back something like:
{ id: 1234, type: 'a', subs: [{ time: 123002, val: 'b' }]}
I want to retrieve that record for example based not on the offset, but based on the 123002 time value.
Possible?
go!