const limit = +res.query.limit || 20 // or by default 20 items
const page = +req.query.page || 1
Events = await EventModels.find({}).sort('-created').skip(limit * page).limit(limit).exec()
I have 5 records, but I don't get anything when I passed limit
to be equal to 100, now I'm confused now the limit
work, I expect to see all of my 5 records when I do .limit(100)
or I messed up with the skip
?
I followed an answer here https://stackoverflow.com/a/14822142/9728810