I have a Collection of documents that looks like this:
[
{
"_id": "588cf61e5120ac11d4366f5c",
"title": "This is a test entry",
"entrybody": "This is the body of an entry",
"creationdate": 1111,
"author": "1223cllclclclc",
"__v": 0
},
{
"_id": "588cf6a556414f02f4e6a865",
"title": "This is a new entry",
"entrybody": "This is the body of an nuew entry",
"creationdate": 11114040050505,
"author": "1223cllclclclclslslsl",
"__v": 0
},
{
"_id": "588cf767fc2ede200cd5738e",
"title": "This is a new entry",
"entrybody": "This is the body of an nuew entry",
"creationdate": 11114040050505,
"author": "1223cllclclclclslslsl",
"__v": 0
}
.....
]
I would like to get the last n records of each author and then order them by creation date, i have looked up how to do this with aggregation but im stuck.
I need the last N documents of the collection that match an especific key e.g author, and then i have to sort that result by "creation date". I think thats different from this question mongodb: how to get the last N records?
Thanks in advance.