can I create a record for a model A and same time ...
# orm-help
a
can I create a record for a model A and same time update a record in model B in same query if model A has a reference of model B?
✅ 1
m
This seems like the perfect time for a $transaction. Anything else seems like a misuse of Prisma to me.
Further, if you start with a create and then go look in your Prisma client, you may see that there's no opportunity to add an update argument as part of a create. Further, if you start with an update, there's no way to add a create argument to the update. Thus, what you really want is $transaction. That's the appropriate use of transaction anyway, if your need is "Add record A if and only if update record B"
a
thank you @Michael Jay 😇
n
As Michael mentioned you are looking for $transactions, it seems an interactive transaction (preview feature) would be ideal in case you need to perform some validation before invoking your second query (update query in your case)