Conversation
|
I don't see any obvious problems, besides the usual duplication of code. @raymondfeng @superkhau PTAL too |
There was a problem hiding this comment.
@bajtos You proposed to use something like this.modifyOrCreate(model, data, options, this.buildReplaceFields, callback) here; however the buildReplaceFields method has this keyword in it; and it breaks var props = this.getModelDefinition(model).properties inside buildReplaceFields method when we pass buildReplaceFields method as the function argument; how about passing the function name like the way I did here and handeling it in modifyOrCreate?
There was a problem hiding this comment.
So there are two ways:
-
use the function name as you suggested, I think it's less clean because you cannot pass an anonymous function
-
pass a wrapper function that preserves
this. You could usethis.buildReplaceFields.bind(this), except thatbindhas terrible performance. Therefore this would be a more performant solution:
var self = this;
this.modifyOrCreate(model, data, options, function(model, data) { return self.buildReplaceFields(model, data); }, callback);|
Hey @raymondfeng, Please also review this patch as well! I really appreciate your time and feedback :-) |
There was a problem hiding this comment.
Just clarifying: buildReplaceFields is a protected method implemented in loopback-connector; please see this PR
|
This is a small patch which is ready for review. I, also, just re-based and squashed the commits into one. Thanks for your time! |
There was a problem hiding this comment.
stick to 80 char limit, this one super long line is hard to read.
There was a problem hiding this comment.
should.equal same for all the ones in the file
273788b to
3eaec8d
Compare
|
LGTM |
There was a problem hiding this comment.
there is an extra space in front of MySQL here
Hi @bajtos,
Please note this is just in progress implementation (Very initial implementation); just to make sure I'm on the right track.
Added functionality:
+Implemented
replaceOrCreatemethod forloopback-connector-mysqlSide note:
loopback-datasource-juggler,loopback-connectoras well.Connect to a spike task: https://github.com/strongloop-internal/scrum-loopback/issues/621
Thanks