NPM Sequelize,其中:[列表]
NPM Sequelize, where: [list]
嘿,我是使用 sequelize ORM 的新手,我无法确定我是否可以在 findAll() 中使用带有列表的位置。
所以这里的 accountIds 是一个 ID 列表,table 我正在搜索我想获取 accountIds 中 accountId 所在的任何行。这是在 sequelize 中执行此操作的正确方法吗?
.findAll({
where: {
accountId: [accountIds]
}
})
确保您的 accountIds 是一个数组。
const Op = Sequelize.Op;
definedTable.findAll({
where: {
zip_code: {
$in: accountIds
}})
前往 进行更复杂的查询
所以在这种情况下,只要 accountIds 是一个数组,它就可以工作,无需添加任何其他内容。
解决方案
.findAll({
where: {
accountId: accountIds
}
})
嘿,我是使用 sequelize ORM 的新手,我无法确定我是否可以在 findAll() 中使用带有列表的位置。
所以这里的 accountIds 是一个 ID 列表,table 我正在搜索我想获取 accountIds 中 accountId 所在的任何行。这是在 sequelize 中执行此操作的正确方法吗?
.findAll({
where: {
accountId: [accountIds]
}
})
确保您的 accountIds 是一个数组。
const Op = Sequelize.Op;
definedTable.findAll({
where: {
zip_code: {
$in: accountIds
}})
前往
所以在这种情况下,只要 accountIds 是一个数组,它就可以工作,无需添加任何其他内容。
解决方案
.findAll({
where: {
accountId: accountIds
}
})