使用sequelize查找“modelA”的所有实例,而不使用“modelB”的相关实例

我正在使用sequelize ,node.js模块。

我想find没有ModelB关联实例的ModelA的所有实例。

ModelA的每个实例都有ModelB的许多实例。

这是我目前没有工作的尝试。

ModelA.findAll({ logging: console.log, where: { //- Where number of ModelB === 0? } include: [ { model: ModelB, where: { //- Where doesn't exist? }, }, ], }) 

我包括了logging:console.log ,以显示它需要输出一个我可以在别处运行的mysql查询,这就是为什么我不只是在返回所有用户之后在promise链中过滤下一个promise的用户。

这应该工作

 ModelA.findAll({ logging: console.log, include: [ { model: ModelB, where: { ModelA_id: {$ne: null} }, }, ], })