// mysql原生语句
select * from user_organization where organization_id in(select id from organization where name like 'ext-%');
求老司机如何写成sequelize的语句?
// mysql原生语句
select * from user_organization where organization_id in(select id from organization where name like 'ext-%');
求老司机如何写成sequelize的语句?
await organizationModel.findAll({
where:{
name: {
$like: 'ext-%'
}
}
}).then(ori => {
// 这里需要修改,不能循环查询数据库
Array.from(ori).forEach(record => {
return userOrganizationModel.findAll({
where: {
'organization_id':record.id
}
}).then(result => {
console.log(result);
ctx.json({
status: 100,
result
});
})
});
}).catch(err => {
console.log(err);
ctx.json({
status: 101
});
});
};
10 回答11.1k 阅读
6 回答3k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
4 回答2.5k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
或者分两步简单查询: