I am trying to achieve one query for below data.
[
{
"blocks": [
{
"issues": {}
},
{
"issues": {
"dt": "dt"
}
}
]
},
{
"blocks": [
{
"issues": {
"ext": "data"
}
}
]
},
{
"blocks": [
{
"issues": {}
}
]
}
]
So, Here are case
from any documents, from any blocks, if any issues object is not empty then skip that document. If blocks having all issues are empty object then return that document.
I tried @elementMatch, $eq, $nin, $ne, @all etc way but not able to solve.
any help would be great
Maybe something like this:
db.collection.find({
$nor: [
{
"blocks": {
$elemMatch: {
"issues": {
$nin: [
{}
]
}
}
}
}
]
})
Explained: Search documents where there is only blocks.issues: {}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.