in the same transaction,can i create a record,and then take id of this record,to update another table which use id ,used to foreignKey #17200
Unanswered
sundalingg
asked this question in
Help & Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
const newGroup = await models.CheckItemsGroup.create({ name: groupId }, { transaction });
if(newGroup){
await models.CheckItems.update({ name: name, groupId: newGroup.dataValues.id }, { where: { id } }, { transaction });
ctx.status = 204;
errMsg = null
await transaction.commit();
}else{
errMsg = '创建分组失败!!!'
throw new Error("创建分组失败!!!");
}
this is my code ,but not work.it always error,say newGroup.dataValues.id ,doesnt exists,my sequlize version is 4.3+
Beta Was this translation helpful? Give feedback.
All reactions