gpt4 book ai didi

sequelize.js - N :M association with Sequelize using MySQL dialect? 上的重叠查询

转载 作者:行者123 更新时间:2023-12-03 22:17:42 25 4
gpt4 key购买 nike

鉴于以下 Sequelize 模型:

models.Post.belongsToMany(models.Tag, {
through: models.PostTag,
foreignKey: 'post_id',
as: 'tags'
});

models.Tag.belongsToMany(models.Post, {
through: models.PostTag,
foreignKey: 'tag_id'
});

我可以像这样查询带有 tag_id = 2 的标签的帖子:
models.Post.findAll({
include: [{
model: models.Tag,
as: 'tags',
where: {
tag_id: 2
}
}]
})

现在,我想查询所有已标记为以下所有标签(tag_id)的帖子:2、5、17、87(或任何其他标签集)。
我使用 MySQL 作为 DB 方言。似乎存在一些可能完成此操作的运算符($overlap、$contains、$contained),但也许这些是特定于 PG 的?

最佳答案

这是目前不可能的。 Sequelize v3.13.0。

关于sequelize.js - N :M association with Sequelize using MySQL dialect? 上的重叠查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33611445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com