我试图2个小时解决一个不是一个小问题。 我在一个生成的yeoman Angular-fullstack应用程序。sequelize,声明(where)在声明(where)
我想与sequelize写这样的代码:
SELECT *
FROM demand
WHERE city_id NOT IN (
SELECT city_id
FROM demand
WHERE user_id=req.params.user_id)
我还没有下面的代码,但不起作用。我只得到[]
export function getCity(req, res) {
return Demand.findAll({
where: {
city_id:{ $notIn: Demand.findAll({
attributes: ['city_id'],
where: {
user_id: req.params.user_id,
}
})}
}
})
.then(handleEntityNotFound(res))
.then(respondWithResult(res))
.catch(handleError(res));
}
你有线索吗? 谢谢。