What would be the best way to atomically update a node using its an existing value (get-and-update)? Seems like the update node Mutation does not have an option of receiving an update-if-exists function.
Locking the object with a write lock, getting the value, updating it and releasing the lock might work but would cause complexity and lots of faulty code I'm trying to avoid.
I'm using MySql with Prisma connector for node.js with a .prisma datamodel.
Prisma 2.1.0 released the first experimental version of transactions via Promises.
Here is the official documentation docs
const write1 = prisma.user.create()
const write2 = prisma.post.create()
const write3 = prisma.profile.create()
await prisma.$transaction([write1, write2, write3])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.