lrf 2 years ago
parent
commit
d5264e83f0
1 changed files with 4 additions and 2 deletions
  1. 4 2
      app/service/view/goods.js

+ 4 - 2
app/service/view/goods.js

@@ -44,12 +44,14 @@ class GoodsService extends CrudService {
     if (sell_num) sort.sell_num = sell_num;
     if (sell_money) sort.sell_money = sell_money;
     if (name) pipline.push({ $match: { name } });
+
+    pipline.push({ $addFields: { goods_id: { $toString: '$_id' } } });
     // 表关联
     pipline.push({
       $lookup: {
         from: 'goodsSpec',
-        localField: 'id',
-        foreignField: 'shop',
+        localField: 'goods_id',
+        foreignField: 'goods',
         as: 'specs',
       },
     });