Skip to content

Commit

Permalink
fix: add id fields in aggregation pipeline (#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
120EE0692 authored Nov 8, 2022
1 parent fad22c7 commit 721df5f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/schema/article/article.datasources.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ const findByYearAndMonth = (allowRestricted, onlyPublished, limit, offset, start
createdAt: { $gte: startAndEndDate[0], $lt: startAndEndDate[1] },
},
},
{
$addFields: {
id: '$_id',
},
},
{
$sort: {
createdAt: 1,
Expand Down Expand Up @@ -173,6 +178,11 @@ const autoComplete = (keyword, allowRestricted, onlyPublished, limit) =>
$and: getBaseConditions(allowRestricted, onlyPublished),
},
},
{
$addFields: {
id: '$_id',
},
},
{
$limit: limit,
},
Expand Down

0 comments on commit 721df5f

Please sign in to comment.