Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 Model.update 中 returning: true, 数据库数据真实被改变,但是没有正确返回对应的数据。并且,使用全局hook 监听不到更新事件。 #16840

Closed
Gf199811 opened this issue Dec 6, 2023 · 1 comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug

Comments

@Gf199811
Copy link

Gf199811 commented Dec 6, 2023

代码如下

异步更新(id:编号,项目:ProjectEntity):Promise<ProjectEntity> { const timestamp = Date.now().toString(16); const secretKey = generateSignature(时间戳,项目); const secretId = uuidv4().replace(/-/g, ''); const updatedProject = { projectName: projectDesc: projectDesc,secretKey: secretKey, secretId } const transaction = await this.sequelize.transaction(); 尝试{ const [rowsAffected, updatedProjects] = await ProjectEntity.updatedProject, { where: { id },returning: true, }); 返回更新的项目[0]; } catch (err) { console.log(err) await transaction.rollback() }
##全局钩子
sequelize.addHook('afterUpdate', async (instance, options) => { await handleHook(instance, options, 'update', redisService); });

@Gf199811 Gf199811 added pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug labels Dec 6, 2023
@WikiRik
Copy link
Member

WikiRik commented Dec 6, 2023

Please ask your questions in English and use the issue template we provide. We can reopen once you have updated your message

@WikiRik WikiRik closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-approval Bug reports that have not been verified yet, or feature requests that have not been accepted yet type: bug
Projects
None yet
Development

No branches or pull requests

2 participants