Hey there, I'm currently working on populating some data and then implementing pagination for that data. Take a look at this example:
Schema A (Users)
{
name: 'Demo',
postId: 'someObjectId',
}
Schema B (Posts)
{
id: 'someObjectId',
postName: 'Post 1',
date: 'date of creation'
}
Let me show you the code snippet:
const users = UserModel.find({
name: 'Demo'
}).populate({
path: 'postId',
select: 'date',
match: {'postId.date' : {$lt: 'today'}}
}).page(pagination).limit(20)
I'm not getting the desired result. Can anyone help me figure out what's wrong?
NOTE: This is just an overview. It doesn't contain actual JavaScript code. I am aware that I haven't included proper JavaScript syntax.