-
Notifications
You must be signed in to change notification settings - Fork 1.2k
allow batch create for persisted models #2879
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
2d78f04 to
b41c339
Compare
|
@bajtos PTAL |
lib/persisted-model.js
Outdated
| accepts: { | ||
| arg: 'data', type: 'object', model: typeName, | ||
| description: 'Model instance data', | ||
| description: 'Model instance data', allowArray: true, |
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.
It's a good practice to keep related things close together and unrelated things apart. IMO, allowArray and description are rather unrelated.
Please move allowArray closer to type/model, e.g. on the previous line.
test/model.test.js
Outdated
| expect(callbackSpy).to.have.been.calledWith(TestModel.sharedClass, 'findOne'); | ||
| }); | ||
|
|
||
| describe('batch operations', 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.
I am proposing to move this new test into describe.onServer('Remote Methods') block as describe('Model.create(data, callback'). I think it would be worth adding two tests - one sending an object, the other sending an array. That way the tests make it clear that both variants are supported.
| it('creates model', function(done) { | ||
| var anObject = { first: 'June' }; | ||
| request(app) | ||
| .post('/users') |
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 noticed the other test cases in this describe is using the method itself instead of going thru strong-remoting
like User.destroyAll(....), instead of POST /users/destroyAll, but that wouldnt be able to verify our scenario that strong-remoting rejects the array. should i add comments to describe why its different?
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.
destroyAll is not exposed via REST.
should i add comments to describe why its different?
yes please, that would be helpful
bajtos
left a comment
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.
👍
| it('creates model', function(done) { | ||
| var anObject = { first: 'June' }; | ||
| request(app) | ||
| .post('/users') |
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.
destroyAll is not exposed via REST.
should i add comments to describe why its different?
yes please, that would be helpful
In strong-remoting 3.x, we have stricken the coercion of inputs methods that are expecting an Object will nolonger accept an array as input, to preserve backwards compatibility we have added flag allowArray in remote arguments, which would accept an array of objects
9a260a4 to
5252fba
Compare
|
updated comments
travis wouldnt pass unless strong-remoting is published |
|
@slnode test please |
2 similar comments
|
@slnode test please |
|
@slnode test please |
connect to strongloop-internal/scrum-loopback#1138
Description
In strong-remoting 3.x, we have stricken the coercion of inputs
methods that are expecting an Object will nolonger accept an array
as input, to preserve backwards compatibility we have added flag
allowArray in remote arguments, which would accept an array of objects
Related issues
Checklist
guide
List of other remoteMethods in persistedModel that receives a
datawithtype:objecti looked at them and dont think they should support batch