I have this following strtucture
{
_id: ".....",
a: {
a1:".......",
b: [
b1: {
b11: "......",
b12: "......",
},
b2: {
b21: "......",
b22: "......",
d: {},
},
c:{
c1: {
......
},
d: {
}
}
]
}
}
here I want to check if property d exists or not inside b, it may exists in multiple objects inside b, if exists pull the d object from record.
Note: There might be a chance that property d exists multiple times inside b1 and b2, In this case I want to remove it from all objects
I tried like
Coll.find({ ‘a.b’: { $elemMatch: { ‘c’: { d: { $exists: true } } } } })
but it is not returning anything although there are records, any help appreciated.
I want to pull that data from record too.
Thanks.
UPDATE
Coll.find({ 'a.b.c.d'{ $exists: true } })
that worked for me but still no idea how to use positional operator to pull the value from record