Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@davidcheung
Copy link
Contributor

@davidcheung davidcheung commented Oct 20, 2016

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

  • None

Checklist

  • New tests are added to cover all changes
  • Code conforms with the style
    guide

List of other remoteMethods in persistedModel that receives a data with type:object
i looked at them and dont think they should support batch

  • patchOrCreate (data)
  • replaceOrCreate (data)
  • upsertWithWhere (where, data)
  • replaceById (id, data)
  • updateAll (where, data)
  • patchAttributes (data)
  • updateLastChange (id, data)

@davidcheung
Copy link
Contributor Author

@bajtos PTAL

accepts: {
arg: 'data', type: 'object', model: typeName,
description: 'Model instance data',
description: 'Model instance data', allowArray: true,
Copy link
Member

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.

expect(callbackSpy).to.have.been.calledWith(TestModel.sharedClass, 'findOne');
});

describe('batch operations', function() {
Copy link
Member

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')
Copy link
Contributor Author

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?

Copy link
Member

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

Copy link
Member

@bajtos bajtos left a 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')
Copy link
Member

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
@davidcheung
Copy link
Contributor Author

updated comments

should i add comments to describe why its different?

yes please, that would be helpful

travis wouldnt pass unless strong-remoting is published
due to strongloop/strong-remoting#369

@davidcheung
Copy link
Contributor Author

@slnode test please

2 similar comments
@davidcheung
Copy link
Contributor Author

@slnode test please

@davidcheung
Copy link
Contributor Author

@slnode test please

@davidcheung davidcheung merged commit ae4d53d into master Oct 26, 2016
@davidcheung davidcheung deleted the batch-create branch October 26, 2016 21:04
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