Skip to content

Commit

Permalink
Merge pull request #209 from Roger13579/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Roger13579 authored Jun 12, 2024
2 parents add29e3 + 3a66156 commit bba7af5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/types/user.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ interface FavoriteItem
| 'amount'
| 'isLaunched'
| 'photoPath'
| 'sellEndAt'
| 'sellStartAt'
| 'sellEndAt'
> {}

Expand Down
28 changes: 13 additions & 15 deletions src/utils/aggregate/user/getFavorite.pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@ import { GetUserFavoriteDTO } from '../../../dto/user/getUserFavoriteDto';
import { Status } from '../../../types/common.type';

const productFields = (isPublic: boolean) => ({
product: {
_id: { $ifNull: ['$product._id', '$favorites.productId'] },
...(isPublic && {
title: '$product.title',
type: '$product.type',
genre: '$product.genre',
price: '$product.price',
soldAmount: '$product.soldAmount',
amount: '$product.amount',
isLaunched: '$product.isLaunched',
photoPath: '$product.photoPath',
sellStartAt: '$product.sellStartAt',
sellEndAt: '$product.sellEndAt',
}),
},
_id: { $ifNull: ['$product._id', '$favorites.productId'] },
...(isPublic && {
title: '$product.title',
type: '$product.type',
genre: '$product.genre',
price: '$product.price',
soldAmount: '$product.soldAmount',
amount: '$product.amount',
isLaunched: '$product.isLaunched',
photoPath: '$product.photoPath',
sellStartAt: '$product.sellStartAt',
sellEndAt: '$product.sellEndAt',
}),
createdAt: '$favorites.createdAt',
updatedAt: '$favorites.updatedAt',
});
Expand Down

0 comments on commit bba7af5

Please sign in to comment.