diff --git a/server-example/server-mysql.js b/server-example/server-mysql.js index 9ef1429..dea89df 100644 --- a/server-example/server-mysql.js +++ b/server-example/server-mysql.js @@ -3794,7 +3794,8 @@ app.post('/api/favorites/list', async (req, res) => { { model: Product, as: 'Product', // 与关联定义中的别名一致 - attributes: ['productId', 'productName', 'price', 'quantity', 'grossWeight', 'imageUrls', 'created_at', 'specification', 'yolk', 'sourceType', 'supplyStatus'] + attributes: ['productId', 'productName', 'price', 'quantity', 'grossWeight', 'imageUrls', 'created_at', 'specification', 'yolk', 'sourceType', 'supplyStatus'], + required: false // 使用LEFT JOIN,即使商品不存在也会返回收藏记录 } ], order: [['date', 'DESC']]