filter the data?
Pradeep-Dhatarwal opened this issue · 3 comments
Pradeep-Dhatarwal commented
can we filter the data coming based on some parameters like catefories and stuff?
aravindnc commented
@Pradeep-Dhatarwal You can pass query object based on your filter. The plugin will only take care of the pagination.
Pradeep-Dhatarwal commented
@Pradeep-Dhatarwal You can pass query object based on your filter. The plugin will only take care of the pagination.
Thanks mate
Pradeep-Dhatarwal commented
I'm fairly new with mongoose.
Can you please help me with this ? (newb question alert !!!)
let posts = await Post.paginate({category : req.query.category}, {
page: req.query.page || 1,
populate: "category",
limit: 5,
sort:{ "date": -1 }
});
here category needs to be populated first as it contains mongoose Object Id mapped to a category schema, but I'm unable to populate it and therefore can't filter the data.
therefore I'm not able to filter the results with category.