回滚后的 Mikroorm id 漏洞

问题描述

我正在将几个实体保存到我的数据库中:

prettier

当其中一个失败时,事务失败并回滚。假设这些任务是它们失败的前 4 个任务,数据库中没有任务,但是下次我插入一个任务时,它从 id 5 开始。有没有办法从持久化的 id 中删除这些任务?

我也在设置 RequestContext:

const tasks = taskInputs.map(task => {
    this.repo.create({
        name,state,});
})
    
try{
    await this.repo.persist(tasks).flush();
}catch(err){
    ...
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)