Skip to content

add allowArray to relations' 'create' remoteMethod#2947

Merged
davidcheung merged 1 commit into
masterfrom
related-models-allow-array
Nov 23, 2016
Merged

add allowArray to relations' 'create' remoteMethod#2947
davidcheung merged 1 commit into
masterfrom
related-models-allow-array

Conversation

@davidcheung

@davidcheung davidcheung commented Nov 15, 2016

Copy link
Copy Markdown
Contributor

connected to #2928

Description

this is a problem where relation's model's remoteMethods are rebuilt (not inherited).
Eg lets say

  • Author.hasMany(Book)
  • POST /book (book.create) has flag allowArray
  • POST /Author/id/Book will rebuild remoteMethod per relation type

Related issues

  • None

Checklist

  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style
    guide

this is needed because we added allowArray flag to persisted model's
remoteMethod, but when relations try to rebuild such methods, it does
not carry over such flags

Update 16/11/16:

  • Just started.

Update 17/11/16:

  • Code is in, could use pre-review

@davidcheung davidcheung self-assigned this Nov 15, 2016
@davidcheung
davidcheung force-pushed the related-models-allow-array branch from 66883ec to 8357390 Compare November 16, 2016 21:53
@davidcheung davidcheung changed the title [wip] inherit accepted from model's remoteMethod inherit accepted from model's remoteMethod Nov 16, 2016
@davidcheung

Copy link
Copy Markdown
Contributor Author

@slnode test please

Comment thread lib/model.js Outdated
accepts: { arg: 'data', type: 'object', model: toModelName, http: { source: 'body' }},
// retrieve original remoteMethod's arguments, so it properly inherits options
accepts: retrieveRemoteMethodInformation.call(this, toModelName, 'create') ?
retrieveRemoteMethodInformation.call(this, toModelName, 'create').accepts[0] :

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bajtos do you think it make sense to try to inherit the accept from the remoteClass, or its too much trouble for too little benefits?
we could also simply just add allowArray here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I would simply copy the allowArray flag. Relation methods are similar but not the same as original DAO methods. In the future, their REST API may diverge, in which case we would not want to share argument metadata.

@davidcheung

Copy link
Copy Markdown
Contributor Author

@slnode test please

1 similar comment
@davidcheung

Copy link
Copy Markdown
Contributor Author

@slnode test please

@davidcheung
davidcheung force-pushed the related-models-allow-array branch from 3052828 to 0f4bd37 Compare November 21, 2016 20:49
@davidcheung davidcheung changed the title inherit accepted from model's remoteMethod add allowArray to relations' remoteMethod Nov 23, 2016
Comment thread test/model.test.js
.end(function(err, result) {
if (err) return done(err);
expect(result.body).to.have.property('id');
expect(result.body).to.have.property('title', aPost.title);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be changed to :
expect(result.body.title).to.eql(aPost.title)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has discussion with @gunjpan decided to keep it the same

@gunjpan gunjpan changed the title add allowArray to relations' remoteMethod add allowArray to relations' 'create' remoteMethod Nov 23, 2016

@gunjpan gunjpan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please resolve conflicts and rebase.

this is needed because we added allowArray flag to persisted model's
remoteMethod, but when relations try to rebuild such methods, it does
not carry over such flags
@davidcheung
davidcheung force-pushed the related-models-allow-array branch from 0f4bd37 to fa7cb92 Compare November 23, 2016 17:10
@davidcheung
davidcheung merged commit a673a38 into master Nov 23, 2016
@davidcheung
davidcheung deleted the related-models-allow-array branch November 23, 2016 19:51
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