hi, I have user and order tables. Order table has ...
# orm-help
a
hi, I have user and order tables. Order table has orderNumber column, not unique. orderNumber must increment by one for each user. How do I implement this? Auto increment won’t work in this scenario as it increments by the total count in the table. Thanks!
n
Hey there 👋 you can do this e.g. with an atomic number operation:
Copy code
await prisma.order.update({
  where: { id: orderId },
  orderNumber: {
    increment: 1
  }
})
a
Thanks a lot for this tip. I have done it in the API by making a count query than incrementing count by 1. I will try what you have suggested later today.
🙌 1