I have this piece of code,
and my after create hook is executing DB queries in the wrong order
afterCreate: async (instance1, { transaction }) => {
const model2 = this.db.getModel('Model2');
// PART 1
const instance2 = await model2.findOne({
where: { id: instance.model2Id },
transaction,
});
// PART 2
return mission.update({...}, { transaction });
}
When using BulkCreate(2 items) I have no idea why order of query execution is,
PART 1(first) -> PART 1(second) -> PART 2(first) -> PART 2(second).
Any hints?
Thanks a lot.