typeorm-transactional-cls-hooked
typeorm-transactional-cls-hooked copied to clipboard
When i use Propagation.NESTED, serializable not work
I write a method A with transaction SERIALIZABLE in my code, and it works as my expect. However, When I add another method B with transaction Propagation.NESTED, and A calls B. I found the transaction A not work like SERIALIZABLE.
This is my code.
@Transactional({ isolationLevel: IsolationLevel.SERIALIZABLE })
async addUserScoreAuto(user: AuthUser) {
await this.service.findOrCreate({ userId: user.id });
}
@Transactional({ propagation: Propagation.NESTED })
async findOrCreate(info: DeepPartial<T>): Promise<[T, boolean]> {
const entity = await this.repo.findOne(info);
if (!entity) {
return [await this.repo.save(info), true];
}
return [entity, false];
}
any news?