-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Docs: How to create a transaction and pass it around through various repo CRUD operations #2614
Closed
7 tasks done
Comments
emonddr
changed the title
Docs: How to open transaction and pass transaction token around
Docs: How to create transaction and pass it around through various repo CRUD operations
Apr 9, 2019
emonddr
changed the title
Docs: How to create transaction and pass it around through various repo CRUD operations
Docs: How to create a transaction and pass it around through various repo CRUD operations
Apr 9, 2019
loopback4-spring arising from Issue #1599 is a good example of using decorator style to perform transaction. |
This was referenced Jun 24, 2019
Merged
This was referenced Jul 19, 2019
Can anybody please give an example of how to use transaction with execute() method. I tried below but not getting expected output. const transaction = await this.employeeRepository.dataSource.beginTransaction(
{isolationLevel: IsolationLevel.READ_COMMITTED}
);
try {
await this.employeeRepository.execute(
`CREATE USER 'TestUser'@'%' IDENTIFIED BY 'TestP@ssword'`,
'', {transaction});
// ... more comands.
await transaction.commit();
} catch {
await transaction.rollback();
} I'm expecting rollback once catch is called. But not able to rollback it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description / Steps to reproduce / Feature proposal
Cross posting my comments:
There are different workarounds that our users have posted:
Loopback 3 provides transaction support at
model
level.In LoopBack 4 this should be at the
Repository
level.There will be
sugar API
in arepository
to delegate the work to thedatasource
level.The
Transaction
type mentioned above should be a wrapper for the typescript type of the transaction object in Juggler.When using the juggler bridge, we need to make sure that the options we set in the wrapper type are consistent with what juggler is expecting.
Since LoopBack 4 doesn't support a distributed transaction, all repos using the transaction must be from the same data source. It is the job of
wrapper
Transaction
to throw an exception if user attempts to use a transaction against disparate data sources.DefaultCRUDRepository will implement an additional interface to handle transactions.
Acceptance criteria
transaction support
in LoopBack 4The text was updated successfully, but these errors were encountered: