I am saving several entities to my database:
const tasks = taskInputs.map(task => {
this.repo.create({
name,
state,
});
})
try{
await this.repo.persist(tasks).flush();
}catch(err){
...
}
When one of them fail transaction fail and it rolls back. Lets say that those tasks were the first 4 tasks they fail no tasks are in the database, but next time I insert a task it starts from id 5. Is there a way to remove those tasks from the persisted ids?
I am also setting RequestContext:
app.use((_req, _res, next) => {
RequestContext.create(orm.em, next);
});