Prisma provides transactional guarantees for neste...
# prisma-whats-new
b
Prisma provides transactional guarantees for nested mutations. If you wanted to do something like transfer 5 coins from player1 to player2, if player1 has 5+ coins, how would you suggest structuring this?
My naive approach would be to create something like:
Copy code
type Player {
name: String! @unique
totalCoins: Int! @default(value: 0)
theBank: Bank!
}

type Bank {
name: String! @unique
player: [Player!]!
}
Where all players are connected to the same bank when created.
h
what's the bank for?
b
It really only provides edges between all players.
h
I mean that would probably be fine
just have to write a resolver for the transaction
b
Would you still have a problem with double spending if you wrapped a query with a nested mutation as a resolver, but multiple requests hit at about the same time?
h
possible
b
Ok, so for this type of use case, it may be better to bypass Prisma and try to call a specific SQL query in the resolver.
Also, thanks for helping me better understand what's going on.
h
prisma doesn't have atomic operations yet
b
I was reading the gh issues and Sorenbs mentioned something about rewriting multiple mutations into a nested one as a workaround for some problems. I was kind of thinking about ways to address this sort of problem.