`@Transactions` decorator, Expose and accept a transaction object
See original GitHub issueProblem
We cannot use a @Transaction
decorator or access the transaction object and pass it directly to the query itself.
Suggested solution
Any thought on doing this: Returning $transaction
to the user and pass it to the API interface as a argument. Something like this:
const transactionObj = prisma.createTransaction();
const user = await prisma.user.create({
data: {
email: 'elsa@prisma.io',
name: 'Elsa Prisma',
},
{ transactions: transactionObj }
})
const temp = prisma.temp.update({ where: { id: 1}, data: {f1: 1}, { transactions: transactionObj }})
TBH I do not like this approach too much (Passing extra stuff, too noisy and annoying)
Alternatives
AFAIK nothing except those listed in the doc which is not practical in most cases.
Issue Analytics
- State:
- Created a year ago
- Comments:19 (5 by maintainers)
Top Results From Across the Web
16. Transaction Management - Spring
Global transactions enable you to work with multiple transactional resources, typically relational databases and message queues. The application server manages ...
Read more >Transactions and Connection Management
When the transactional state is completed after a rollback or commit, the Session releases all Transaction and Connection resources, and goes back to...
Read more >Using database transactions | LoopBack Documentation
Handling Transactions · Start a new transaction. · Perform create, read, update, and delete operations in the transaction. · Commit or rollback the...
Read more >Transactions and db_session — Pony ORM documentation
This approach guarantees that there will be no lost updates, the situation when during the current transaction another transaction changed the same object...
Read more >c# - Can I get a reference to a pending transaction from a ...
The command object can only be assigned a transaction object using one ... Transactions approach uses in conjunction with SQL Server 2005 a ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
please have a look at https://github.com/prisma/prisma/issues/12975, that discusses the same topic. And also have a look at https://github.com/prisma/prisma/issues/12458
The problems discussed in https://github.com/prisma/prisma/issues/12458 regarding the test situation would also be solved with a
@Transactional
annotation.As said in my other comments in the other issues, this is more or less a standart in the Spring Hibernate world.
I think OP and me are talking about Prisma providing a @transaction decorator which would provide a transaction for the functions execute below. I don’t have expertise to say if this is difficult to implement.
Of course, this is not blocking, the actual $transaction works pretty well.
But a decorator would provide more readability for the code.