Hi, I’m going to ask you for help with a rather different situation. I’m not sure such a query is possible. I hope there is a solution.
db
{
users: [
{
_id: 1,
userid: "user1",
title: "title 1",
content: "content 1",
createdAt: 08
},
{
_id: 2,
userid: "user2",
title: "title 2",
content: "content 2",
createdAt: 10
},
{
_id: 3,
userid: "user2",
title: "title 3",
content: "content 3",
createdAt: 12
},
{
_id: 4,
userid: "user3",
title: "title 4",
content: "content 4",
createdAt: 13
}
]
}
(second and third post belong to the same user)
I want to use the following array as parameter.
[{ userid: "user1", lastAccessDate: 07, }, { userid: "user2", lastAccessDate: 11, }]
1- I want to list the posts of the users in the array.
2- But I want to list the posts whose “createdAt” value is greater than “lastAccessDate” value in the same index.
My English is not enough. I hope I was able to explain.
According to the example and conditions I gave, posts with id 1 and 3 will be listed.
Please help me how to do this.
Sorry if I was rude. Have a nice day