for my new project we started to use mongodb as a document repository. It works great for our requirements but now we need to implement a more advanced query on sub-sub-arr
Since there is no way to tell what driver you use here is a shell solution:
db.foo.find({
"Asset.Metadata.Platforms.Platform": {
$elemMatch: {
"@name": VAR_PLATFORM,
"PublishingRanges.PublishingRange": {
$elemMatch: {
"@startdate": {$gt: VAR_START},
"@enddate": {$lt: VAR_END}
}
}
}
}
})
By the way, you could simplify document structure by omitting Platform
and PublishingRange
and assigning arrays to Platforms
an PublishingRanges
respectively.