I’m running the following query
const query = {
$and: [
{
$or: [
{
status: ‘PROCESSED’
},
{
status: ‘IN_PROGRESS’
},
],
},
{
content_id: { $in: contentIds },
},
],
};
in order to obtain all the data where the content_id
is in a given list. I would like to obtain the 5 most recent data items for each content_id
.
I know I can accomplish this by running an individual query for each content id, sorting by content_date
DESC
and setting a limit of 5 - I would like to achieve all of this in one query, rather than running individual ones for each content id, is this possible?
question from:
https://stackoverflow.com/questions/65934428/query-with-in-operator-and-limit-on-amount-of-data-loaded 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…