PrismaP
Prisma8mo ago
3 replies
ptrxyz

About transactions and extensions

I want to add custom methods to my model:

export default Prisma.defineExtension((c) => 
  return {
    model: {
      user: {
        doCreate: async (name: string) => {
          return await c.user.create({ data: { name } });
        },
      },
    }
  }
})

This doesn't seem to work when I call the method inside a transaction. I found this:
https://www.prisma.io/docs/orm/prisma-client/client-extensions/shared-extensions#call-a-client-level-method-from-your-packaged-extension

Does this apply here? Or am I doing it wrong?
Was this page helpful?