यदि यह सभी या प्रदर्शित करने से संबंधित है, तो पेजिनेशन नीचे दिए गए कोड की तरह कुछ होगा। कोड सिर्फ एक उदाहरण है:
findAll: async function (req, res) {
var responseObj = {};
try {
var responseObj = {};
var queryArray = [];
var finalAnswer = [];
var loggedinUser = mongoose.Types.ObjectId(req.user.id)
var auser = await user.findOne({ _id: loggedinUser })
var places = auser.placesUnderIt;
for (i of places) {
var singlePlaceId = mongoose.Types.ObjectId(i);
var singlePlaceData = await place.findOne({ _id: singlePlaceId })
var list = singlePlaceData.controlledStore;
for (k of list) {
finalAnswer.push(k);
}
}
queryArray.push({ _id: { $in: finalAnswer} });
var query = {
$and: queryArray
}
responseObj.count = await store.countDocuments(query);
responseObj.data = await store.find(query)
.populate('ownerId', ["firstName", "lastName", "phoneNumber", "email", "personalDetails"])
.populate('businesses')
.limit(parseInt(req.query.limit))
.skip(parseInt(req.query.skip));
var data = responseObj.data;
return res.send(responseObj);
} catch (err) {
return res.send('Error');
}
}