node.js - 回滚后的 Mikroorm id 漏洞
问题描述
我将几个实体保存到我的数据库中:
const tasks = taskInputs.map(task => {
this.repo.create({
name,
state,
});
})
try{
await this.repo.persist(tasks).flush();
}catch(err){
...
}
当其中一个失败时,事务失败并回滚。假设这些任务是他们失败的前 4 个任务,数据库中没有任务,但是下次我插入一个任务时,它从 id 5 开始。有没有办法从持久的 id 中删除这些任务?
我也在设置RequestContext:
app.use((_req, _res, next) => {
RequestContext.create(orm.em, next);
});
解决方案
推荐阅读
- c# - Xamarin 将参数从后面的代码传递到不同的 xaml
- bash - bash' 内置声明 -nz 对 z 参数有什么作用?
- javascript - 为什么不能用 document.forms 选择标签?
- wso2 - wso2 api manager schannel: next InitializeSecurityContext failed-证书链是由不受信任的权威机构颁发的
- xml - visual studio 2019 xslt 调试启用文档功能
- python - 如何在 matplotlib 中使用 Nimbus Roman 字体?
- python - 访问谷歌存储桶的问题
- java - 如何将 H2 控制台嵌入 WAR
- javascript - 将表单数据发送到 Firebase
- rest - 以更精确的方式理解 SOAP 与 REST