Closed EliArad closed 8 years ago
You can use the match
option of Mongoose populate (see this. Populate options can be specified via the plugin options.
I have the same problem, but i'm not sure your suggestion works for me.
An instance of my model Tickets is being populated through the Store model by: store_id, store_id.company_id and store_id.city_id.
I need that the resultant array be filtered by a store_id.company_id.companyName === 'someCompany'.
I tried adding the $match option on each of the levels listed below (4) and it didn't worked for me.
How would be the best way to accomplish this?
Level1 --- tickets.find({})
Level2 --- .then(tks1 => store.populate(tks1, {path: "store_id"}))
Level3 --- .then(tks2 => company.populate(tks2, {path: "store_id.company_id"}))
Level4 --- .then(tks3 => city.populate(tks3, {path: "store_id.city_id}))
.then(result=>{ })
@buunguyen
I did population and i am getting all the data
But i want to do find with criteria on the nested path I only able to perform find with objects on the root Is it posdible? If so can you please give example of such query? Thank you Eli