【发布时间】:2021-12-05 12:20:29
【问题描述】:
大家好,我使用 node-express 和 sequelize 时,每当我使用此查询时,我得到的计数不正确。标签产品在返回计数 3 时包含一个产品。 代码如下
let product = await model.Product.findAndCountAll({
where:condition,
attributes:['id' , 'product_name' , 'description' , 'model_information' , 'brand', 'ProductWarrenty' , 'WarrentyDuration' , [price ,'price']],
include:[{
model:model.Category,as:'productcategory'
} , {
model:model.SubCategory, as:'ProductSubCategory'
} , {
model:model.ProductImages,as:'product_images'
}],
offset: offset,
limit: 14,
order: [sorting]
})
product 表有 1 条记录,但它返回 3 条记录。
【问题讨论】:
标签: javascript mysql node.js express sequelize.js