PrismaP
Prisma6mo ago
4 replies
Darkstar

Using increment on Decimal fields?

In the docs, it explicitly mentions atomic number operations like increment, decrement etc. only works on Float and Int. https://www.prisma.io/docs/orm/reference/prisma-client-reference#atomic-number-operations

However, I tried it on a Decimal field, and it seems to work fine. Does that mean I can use it without any issues? Or are there any issues that could pop up?

Part of my schema:
model Pot {
  id            String   @id @default(cuid())
  currentAmount Decimal  @default(0.00) @db.Decimal(12, 2)
}

Query:
await prisma.pot.update({
   where: { userId, potId },
   data: { currentAmount: { increment: amountToUpdate } },
  })

amountToUpdate is a string.
Was this page helpful?