Skip to content

Commit

Permalink
[Issue #158] Handle 'hasMany' and 'belongsToMany' in switch statement (
Browse files Browse the repository at this point in the history
  • Loading branch information
Russ Nicoletti authored and ferjm committed Feb 1, 2017
1 parent 9616d06 commit f00bb66
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/middlewares/associations.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,14 @@ export default version => {
ERR.BAD_REQUEST);
}

const type = association.associationType;
if ([hasMany, belongsToMany].indexOf(type) > -1) {
return verifyAssociations(resourcesLeft, resource, previousResource);
}

// Check that the association between the two entities actually exists.
previousModel.findById(previousId).then(previousEntity => {
if (!previousEntity) {
return ERR.ApiError(res, 404, ERR.ERRNO_RESOURCE_NOT_FOUND,
ERR.NOT_FOUND);
}

const type = association.associationType;
const name = model.options.name.singular;

switch (type) {
Expand Down

0 comments on commit f00bb66

Please sign in to comment.