Skip to content
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

add runInTransaction and wrapInTransaction #94

Merged
merged 2 commits into from
May 15, 2021
Merged

add runInTransaction and wrapInTransaction #94

merged 2 commits into from
May 15, 2021

Conversation

lytc
Copy link
Contributor

@lytc lytc commented Mar 30, 2021

Hi @odavid , I created this PR for this request #92, could you help to have a look?

package.json Outdated
@@ -38,7 +38,8 @@
},
"dependencies": {
"@types/cls-hooked": "^4.2.1",
"cls-hooked": "^4.2.2"
"cls-hooked": "^4.2.2",
"delay": "^5.0.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change this dependency to be a dev dependency

}

return wrapped as Func;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a newline here...

@odavid
Copy link
Owner

odavid commented Apr 3, 2021

Hi @lytc, thanks for the contribution!

I feel you also need to add the runInTransaction function to the exports within the index.ts

@koenpunt
Copy link

koenpunt commented Apr 6, 2021

Not sure if this is the correct thread to bring this up, but I feel it might be related; I'm using this library indirectly (through typeorm-test-transactions), and I was wondering if it would possible to have separate "start" and "stop" transaction methods? So not a function wrapper (or decorator).

I hope to be able to use it in before/after hooks of jest, to automatically "wrap" every test in a transaction;

beforeEach(() => startTransaction());

test('do something with the database', async () => {
  await someDbAction();
});

afterEach(() => rollbackTransaction());

Or more plainly;

await startTransaction();
await someDbAction();
await rollbackTransaction();

@lytc
Copy link
Contributor Author

lytc commented Apr 7, 2021

Hi @lytc, thanks for the contribution!

I feel you also need to add the runInTransaction function to the exports within the index.ts

I added that already!

@lytc lytc closed this Apr 7, 2021
@lytc lytc reopened this Apr 7, 2021
@lytc
Copy link
Contributor Author

lytc commented Apr 7, 2021

Hi @odavid ,
Thanks for your review, I make the change regarding to your comments!

@odavid odavid merged commit f3de675 into odavid:master May 15, 2021
@odavid
Copy link
Owner

odavid commented May 15, 2021

Thank you!

Aliheym pushed a commit to Aliheym/typeorm-transactional that referenced this pull request Jul 31, 2022
* add runInTransaction, wrapInTransaction

* change dependency of delay to dev dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants