来自sequelizeJS docs的这个例子并没有像上面提到的那样工作。这是link。
// check if all associated objects are as expected:
// let's assume we have already a project and two users
project.setUsers([user1, user2]).then(() => {
return project.hasUsers([user1]);
}).then(result => {
// result would be false // For me it is returning true
return project.hasUsers([user1, user2]);
}).then(result => {
// result would be true
})
重现
假设一个项目为2个用户user1,user2。 hasUsers() 此方案返回true而不是false。
project.hasUsers([user1]); // => returns true instead of false