Skip to content

Commit

Permalink
fix(endpoint:controller): wrap saveUpdates in an if(entity) statement
Browse files Browse the repository at this point in the history
fixes #2052, closes #2059
  • Loading branch information
Kevin Wang authored and Awk34 committed Sep 13, 2016
1 parent 1fbf24b commit 31c0a79
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions templates/endpoint/basename.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ function respondWithResult(res, statusCode) {

function saveUpdates(updates) {
return function(entity) {
<% if (filters.mongooseModels) { %>var updated = _.merge(entity, updates);
return updated.save()
.then(updated => {<% }
if (filters.sequelizeModels) { %>return entity.updateAttributes(updates)
.then(updated => {<% } %>
return updated;
});
if(entity) {
<% if (filters.mongooseModels) { %>var updated = _.merge(entity, updates);
return updated.save()
.then(updated => {<% }
if (filters.sequelizeModels) { %>return entity.updateAttributes(updates)
.then(updated => {<% } %>
return updated;
});
}
};
}

Expand Down

0 comments on commit 31c0a79

Please sign in to comment.