I'm using javascript and the mongoose module. I have an object like this
my_object = {
ShopName: String,
employees: [String],
info: {
NameEmployee_1: {
age: String,
work: String,
city: String,
},
NameEmployee_2: {
age: String,
work: String,
city: String,
}
}
}
and i want find all the emoplyees that have a specific age but without knowing the name of the emplyee, is there a way for do this?
I know that you for example i can so something like this
db.collection.find({'info.Max': {$exists: true}})
for find all the Shops that have atleast one employee with name Max but what if i want all the Shops that have atleast one emplyee that has age 33
db.collection.find({'info.<name>.age': '33'}) ?