Hello good evening can someone help me with this question please. I want to bring all the users by the name of the area when it exists. But the name of the area is in a populate.
I have the image but it doesn’t work for me
2
You can’t query by populate.
But you can implement that instead:
Area
nombre_area
User
areaI
It’s simple and should be performant, as I believe you don’t have thousands of areas.
you have two solutions
1- separate the query and write a method & named it aeraExist(name) and filter it by name
2- in the populate add match & if that filter doesn’t match it will return null
.populate({ path: "areaI", match: {name: "Us"}, })
Click here to cancel reply.
2
Answers
You can’t query by populate.
But you can implement that instead:
Area
bynombre_area
User
s withareaI
equal to that area idIt’s simple and should be performant, as I believe you don’t have thousands of areas.
you have two solutions
1- separate the query and write a method & named it aeraExist(name) and filter it by name
2- in the populate add match & if that filter doesn’t match it will return null