-
Notifications
You must be signed in to change notification settings - Fork 86
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
Conversation
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" |
There was a problem hiding this comment.
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
src/wrapInTransaction.ts
Outdated
} | ||
|
||
return wrapped as Func; | ||
} |
There was a problem hiding this comment.
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...
Hi @lytc, thanks for the contribution! I feel you also need to add the |
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(); |
I added that already! |
Hi @odavid , |
Thank you! |
* add runInTransaction, wrapInTransaction * change dependency of delay to dev dependency
Hi @odavid , I created this PR for this request #92, could you help to have a look?