I am using the prisma ORM and NestJS and I got the following example code:
async createMerchant(data: Prisma.MerchantCreateInput): Promise<Merchant> {
return await this.prisma.$transaction(async (): Promise<Merchant> => {
await this.prisma.merchant.create({
data,
});
throw new Error(`Some error`);
});
}
I would expect that the transaction is rolled back as I have thrown an error, but it is not, it creates a new database entry.
Here is the example of the official documentation.
Is this maybe related to the dependency injection of NestJS and that the injected prisma service is not correctly recognizing the error? Or am I doing something wrong?