-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating associated data transactionally #236
Comments
The situation you describe could be implemented in multiple ways, none of which are actually possible yet: BatchingI've been thinking about how batching multiple types of query containers at the same time could work, since Prisma Client JS allows you to batch whatever you want. In your example, something like Allowing this would require some extra work on my part, since I'd have to keep track of how many queries were provided to each tuple and I may try implement this for 0.6.4 since it makes the ergonomics of batching much nicer. Nested Writes (#44)Nested writes would be performed in a transaction, that's just how Prisma works. Not much more to say there. Interactive Transactions (#60)On the |
Gonna ship the nested batching (#237) in 0.6.4, so that'll be your best option once that's released. |
Thanks for the quick work! Exciting to hear that interactive transactions are on the way too -- they solve a whole category of problems that are hard to work around otherwise, even if they're a bit of a blunt instrument in cases where nested writes or batching would suffice. |
Hi again -- I'm following up from #234 (since this seems like a distinct issue and since I know some maintainers don't check closed issues as a matter of course).
I'm trying to create some associated data transactionally with
_batch()
, but it doesn't seem possible to create heterogeneous, dynamically-sized data at the moment.For example, I'd like to create a
Post
alongside a variable number ofTag
s based on some input data; as discussed in #234, I'm upserting the tags instead of usingconnectOrCreate
. But if the creating thePost
fails for whatever reason, I'd like the data to remain in a consistent state -- any previously-createdTag
s should be rolled back.It seems like I can batch a fixed number of heterogeneous operations by passing a tuple to
_batch()
, or I can batch a variable number of operations of the same type by passing an iterable. But if I don't know the number ofTag
s to be created, I can't create them and thePost
in a single transaction. Is that correct?As far as I can tell, there's no escape valve for this at the moment either, right? I don't believe I can execute a series of raw statements that start with
BEGIN
and end withCOMMIT
, say.The text was updated successfully, but these errors were encountered: