I am trying to filter and paginate data from my API, but I keep getting an error. here is the code I am trying to use to achieve that.
router.get('/api/place', async (req, res) => { // pagination and filter // const match = {} const noOnPage = parseInt(req.query.limit) || 10 const pageNo = (parseInt(req.query.page)-1)*parseInt(req.query.limit) try { const place = await Place.find({ isOpen: true }) .populate({ select: '-media', match, options: { limit: noOnPage, skip: pageNo } }) .exec() console.log("hello"); res.status(200).send(place) } catch (e) { res.status(500).send() } })
please what could I be missing?
remove match and set path argument with name of field that has ref
match
path
ref
const place = await Place.find({ isOpen: true }) .populate({ path: 'user', select: '-media', options: { limit: noOnPage, skip: pageNo } })
1.4m articles
1.4m replys
5 comments
57.0k users