Skip to content

Commit

Permalink
[Fix]: fix missing mysql id on search results (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
Istiopaxx authored Nov 30, 2023
1 parent abb21c2 commit dd254ea
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions api/libs/recipe/src/repositories/recipe/mongo.recipe.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,28 @@ export class MongoRecipeRepository {
? 'score'
: textSearchRecipeDto.sort]: -1,
})
.project({
_id: 0,
__v: 0,
recipe_raw_text: 0,
origin_url: 0,
recipe_steps: 0,
ingredient_requirements: 0,
})
.facet({
recipes: [{ $skip: (page - 1) * limit }, { $limit: limit }],
recipes: [
{
$addFields: {
mongo_id: '$id',
id: '$mysql_id',
},
},
{
$project: {
_id: 0,
__v: 0,
mysql_id: 0,
recipe_raw_text: 0,
origin_url: 0,
recipe_steps: 0,
ingredient_requirements: 0,
},
},
{ $skip: (page - 1) * limit },
{ $limit: limit },
],
count: [{ $count: 'count' }],
})
.pipeline();
Expand Down

0 comments on commit dd254ea

Please sign in to comment.