|
@@ -59,8 +59,8 @@ class GoodsService extends CrudService {
|
|
|
});
|
|
|
// 按照规格平铺数据
|
|
|
pipline.push({ $unwind: '$specs' });
|
|
|
- // 格式化平铺后的数据
|
|
|
- pipline.push({ $project: { name: 1, view_num: 1, sell_num: 1, file: 1, sell_money: { $toDouble: '$specs.sell_money' }, meta: 1 } });
|
|
|
+ // // 格式化平铺后的数据
|
|
|
+ pipline.push({ $project: { name: 1, view_num: 1, sell_num: 1, file: 1, sell_money: { $toDouble: '$specs.sell_money' }, createdAt: '$meta.createdAt' } });
|
|
|
pipline.push({
|
|
|
$group: {
|
|
|
_id: '$_id',
|
|
@@ -69,6 +69,7 @@ class GoodsService extends CrudService {
|
|
|
sell_num: { $first: '$sell_num' },
|
|
|
sell_money: { $min: '$sell_money' },
|
|
|
file: { $first: '$file' },
|
|
|
+ createdAt: { $first: '$createdAt' },
|
|
|
},
|
|
|
});
|
|
|
// 排序处理
|
|
@@ -78,6 +79,7 @@ class GoodsService extends CrudService {
|
|
|
// 分页处理
|
|
|
if (parseInt(skip)) pipline.push({ $skip: parseInt(skip) });
|
|
|
if (parseInt(limit)) pipline.push({ $limit: parseInt(limit) });
|
|
|
+ pipline.push({ $sort: { createdAt: -1 } });
|
|
|
const list = await this.goodsModel.aggregate(pipline);
|
|
|
return list;
|
|
|
}
|