is the `transaction` comparable with `Promise.all(...
# orm-help
d
is the
transaction
comparable with
Promise.all()
, if yes, does multiple prisma queries with with
Promise.all()
?
r
@Dev__ ๐Ÿ‘‹ No itโ€™s not.
$transaction
will rollback all your queries even if a single one fails (just like database transactions) where as
Promise.all
will not rollback the completed ones in case a single one fails. Also
$transaction
will run the statements one after another where as
Promise.all
will run in parallel.
d
is there a way to perform a transaction where a query depends on the previous query's result? example
Copy code
transaction([
   query1,
   query2(query1.id)
])
r
We will be releasing a version of how you can perform this in a coming release ๐Ÿ™‚
Could you share your use case for using the
id
? Can it be performed using nested writes?
h
Is there a way to use this to dynamically add queries to be executed in the same tranasction?