question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API for interactive transactions with dependencies between write-operations

See original GitHub issue

There already is a GitHub issue asking for a way to submit multiple mutations within the same HTTP request where all mutations are executed as one transaction.

However, this feature does not allow for creating a transaction where the mutations depend on each other. Here is an example where the second operation depends on the first:

prisma.transaction(async tx => {
  const user = await tx.createUser({
    name,
  })
  // compute some stuff
  await tx.updateOrder(user.id)
  await tx.commit()
})

This is currently not possible with the Prisma API as it would require having a long-running connection where the results of the operations are sent back and forth between Prisma and the database.

It should be considered whether it is helpful to add such an API to Prisma, or whether abstractions like nested mutations and the requested transactional execution of multiple independent transactions are the better approach for Prisma.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:195
  • Comments:122 (43 by maintainers)

github_iconTop GitHub Comments

109reactions
thebiglabaskycommented, May 22, 2021

Hi everyone,

We heard you loud and clear: most of you want to have that flexibility to choose when to use LRT and when not to, without being left with no other alternative than going through an entirely separate client or solution.

As mentioned earlier in this thread a while back, we do indeed want to give the ability to use long-running transactions in cases where they’re not a genuine concern or people do not have the choice to do otherwise (e.g. incrementally porting existing applications without rethinking their entire logic). This wasn’t prioritized so far as we wanted to make good strides on the topics at the forefront of our roadmap, specifically with our upcoming MongoDB connector, which is taking us a lot of effort right now.

We are starting the design work required to enable long-running transactions with Prisma Client, and greatly appreciate the suggestions put forward in this thread. At the same time, we recognize that many use cases are better solved using other approaches, and we will continue to invest heavily in Prisma Client to make sure you can do most of your work without having to resort to long-running transactions.

We will keep you posted with design proposals for that as we progress, and you should expect to see movement before or during summer on the topic.

Thanks for continuing to share your use cases, and staying constructive in your feedback, this greatly helps us improving Prisma!

57reactions
dpetrickcommented, Jul 27, 2021

Heads-up: We have internal prototypes running and we’re aiming for a preview release in 2.29, if no major blockers are uncovered along the way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transactions and batch queries (Reference) - Prisma
Interactive transactions : pass a function that can contain user code including Prisma Client queries, non-Prisma code and other control flow to be...
Read more >
Jay Phelps on Twitter: "It looks like in Prisma there's no built-in way ...
API for interactive transactions with dependencies between write-operations · Issue #1844 ·... There already is a GitHub issue asking for a way to...
Read more >
Batch Operations in Aerospike | Developer Hub
An interactive Jupyter notebook tutorial illustrating the Aerospike batch operations using Java.
Read more >
Livy API reference for interactive sessions | CDP Private Cloud
GET /sessions/{sessionId}/logs retrieves log records for the specified session. Request Parameters, Description, Type. from, Offset, int.
Read more >
Lettuce Reference Guide
The interactive tutorial introduces Redis. ... Where to go from here ... dependencies { implementation 'io.lettuce:lettuce-core:6.2.2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found