Solving the n+1 problem
https://www.prisma.io/docs/guides/performance-and-optimization/query-optimization-performance
https://www.prisma.io/docs/concepts/components/prisma-client/transactions
- timeout: The maximum amount of time the interactive transaction can run before being canceled and rolled back. The default value is 5 seconds.
- デフォルトのタイムアウトは 5 秒
書き方は 2 種類
const [user, profile] = await prisma.$transaction([
prisma.user.create({ data: ...{} }),
prisma.profile.create({ data: ...{} }),
]);
const [user, profile] = await prisma.$transaction(async (tx) => {
const user = await tx.user.create({ data: ...{} });
const profile = await tx.profile.create({ data: ...{} });
return [user, profile];
});
jest.resetModules() https://jestjs.io/docs/ja/jest-object#jestresetmodules jest.unmock() https://jestjs.io/docs/ja/jest-object#jestunmockmodulename