亲爱的
我试图选择内部包括sequelizejs的数量,但我得到的错误如下
Unhandled rejection SequelizeBaseError: ER_BAD_FIELD_ERROR: Unknown column 'User.Orders.id' in 'field list'
at Query.formatError (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/sequelize/lib/dialects/mysql/query.js:175:14)
at Query._callback (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/sequelize/lib/dialects/mysql/query.js:49:21)
at Query.Sequence.end (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/mysql/lib/protocol/sequences/Sequence.js:86:24)
at Query.ErrorPacket (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/mysql/lib/protocol/sequences/Query.js:88:8)
at Protocol._parsePacket (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/mysql/lib/protocol/Protocol.js:280:23)
at Parser.write (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/mysql/lib/protocol/Parser.js:75:12)
at Protocol.write (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/Users/abdulazizaltaleb/Desktop/Ajeer-Dashboard_clone/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:115:13)
at Socket.emit (events.js:210:7)
at addChunk (_stream_readable.js:252:12)
at readableAddChunk (_stream_readable.js:239:11)
at Socket.Readable.push (_stream_readable.js:197:10)
at TCP.onread (net.js:589:20)
我需要的只是从模型中返回数据并将这些数据包含在其他人中以获取计数
在我的代码下方,我在代码中使用了一些解释
models.Order.findAll({
where : {
userId : {
$and : {
$notIn: ['null']
}
},
serviceId : {
$and : {
$notIn: ['null']
}
}
},
limit : 10,
pageLength : 500,
order: '`id` DESC',
include: [
{
model : models.User,attributes : ['firstName','lastName','phoneNumber','rankId'],
include: [
{
model : models.Order
// return the count for orders
}
]
}
],
attributes: ['id','serviceId','orderStatus',
[sequelize.Sequelize.fn('COUNT', sequelize.Sequelize.col('User.Orders.id')), 'count']
],
group: ['`User.Orders`.`userId`']
所以在行
// return the count for orders
我正在尝试获取模型的计数
model : models.Order
谢谢