prisma - quick model update and save?

Viewed 290

Just wondering if I'm missing something in prisma. if i have a working object and choose to modify it, can I just "save" that object like in most ORMs?

otherwise I have to duplicate all the code including all the field changes.


// findOrCreate:
const user = await prisma.user.upsert({ ...

user.balance += 1

await user.save() // doesn't work

// so i have to do all this?
await prisma.user.update({ 
  where: { id: user.id }, 
  data: { balance: user.balance } })

I assume there's a more concise syntax to do this but wan't able to google it.

0 Answers
Related