Closed iamhaaamed closed 3 years ago
I don't use mongodb, so I don't know, but..
I suggest you look at src/routes/v1/user.route.js
and try that approach.
Other than that, go check out Express and Mongoose documentation.
{
"results": [
{
"price": 3000,
"name": "Sg",
"user": {
"role": "admin",
"id": "608cbaa42f8c662457960b94"
},
"id": "608e9ef6785cb5002008565a"
},
{
"price": 3000,
"name": "Sg",
"user": {
"role": "admin",
"id": "608cbaa42f8c662457960b94"
},
"id": "608e9fdd785cb5002008565b"
},
{
"name": "Aaa",
"user": {
"role": "admin",
"id": "608cbaa42f8c662457960b94"
},
"id": "608ea017785cb5002008565c"
}
],
"page": 1,
"limit": 10,
"totalPages": 1,
"totalResults": 7
}
I have this query results:
{ "results": [ { "price": 3000, "name": "Sg", "user": { "role": "admin", "id": "608cbaa42f8c662457960b94" }, "id": "608e9ef6785cb5002008565a" }, { "price": 3000, "name": "Sg", "user": { "role": "admin", "id": "608cbaa42f8c662457960b94" }, "id": "608e9fdd785cb5002008565b" }, { "name": "Aaa", "user": { "role": "admin", "id": "608cbaa42f8c662457960b94" }, "id": "608ea017785cb5002008565c" } ], "page": 1, "limit": 10, "totalPages": 1, "totalResults": 7 }
and when I want to filter the results by user id like this:.../v1/products?user=608ebf9a785cb50020085661
it returns all the results... I want to know that is it possible to filter the queries by ref props?