-
Notifications
You must be signed in to change notification settings - Fork 100
chore: add promise support to Transaction methods #147
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
Conversation
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.
@b-admike 👍 I left a suggestion regarding the test.
test/transaction.test.js
Outdated
}); | ||
}); | ||
|
||
it('can return promise', function() { |
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.
A suggestion (I am not confident to say it would be a better testing approach :p)
We can test a promise returned by calling those chain methods like .then()
, see example in juggler https://github.com/strongloop/loopback-datasource-juggler/blob/de4718d5b81d29ac23597172d8ee591617924fe0/test/transaction.test.js#L94
7b8d7f4
to
f63ff39
Compare
lib/transaction.js
Outdated
*/ | ||
Transaction.prototype.commit = function(cb) { | ||
cb = cb || createPromiseCallback(); | ||
return this.connector.commit(this.connection, cb); |
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.
I think you need to return cb.promise
.
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.
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.
Thanks @raymondfeng 🙇 that is correct.
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.
Good start!
069d9a8
to
494b260
Compare
test/transaction.test.js
Outdated
}; | ||
|
||
return expect( | ||
Transaction.begin(connectorObject, '')).to.eventually.be.instanceOf(Transaction); |
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.
I think we are usually using slightly different formatting.
LB3 style:
return expect(Transaction.begin(connectorObject, ''))
.to.eventually.be.instanceOf(Transaction);
LB4 style (?)
return expect(
Transaction.begin(connectorObject, '')
).to.eventually.be.instanceOf(Transaction);
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.
Okay I'll go with LB3 (EDIT LB4) style 👍
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.
LGTM. Please get @raymondfeng's approval before landing.
Add promise support to transaction methods. Co-Authored-By: Miroslav Bajtoš <mbajtoss@gmail.com>
494b260
to
d79092a
Compare
I've looked at the failed builds, and none of them seem related to changes in this PR. Will merge as is. |
Description
Add promise support to transaction class methods.
Related issues
Checklist
guide