【发布时间】:2019-12-07 14:05:36
【问题描述】:
我有一个用户和一个国家模型。用户属于许多国家,反之亦然。
如何查询countries数组中只有特定国家ID的用户?
const users = await DB.User.findAll({
where: {
// What to put here?
},
include: [
{
model: DB.Country,
as: 'countries',
// Putting where here only causes the countries to filter
},
],
});
【问题讨论】: