I have next article structure:
var articleSchema=new Schema({
id : Number,
title : String,
sefriendly : String,
created : Date,
categories: [
{
id: Number,
name: String,
sefriendly: String,
image: String
}
],
author: {
id: Number,
name: String
}
});
So what I want is to take one latest article sorted by created
field for a set of categoryIds
. For example I have categories like Cinema, TV, Music, Books, and I want to take latest article for each category. Is it possible to do in one query?