Hello,
I have created a smart-segment and I’m trying to get pagination to work. The documentation shows how to set arbitrary limit to the number of results, but not how to implement proper pagination. How can I get the proper values I should set as $limit
and $skip
? My where
function doesn’t seem to receive any useful arguments.
My project is using forest-express-mongoose 8.3.9
{
name: "Segment name",
where: () => {
return model.find({
isActive: true,
},
[
{
$project: { _id: true },
},
{
$sort: { updatedAt: -1 },
},
{
$limit: "???",
},
{
$skip: "???",
},
])
.then((spots) => ({
_id: { $in: spots.map(({ _id }) => _id).filter(Boolean) },
}));
},
};