Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/endpoint/basename.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function upsert(req, res) {
delete req.body._id;
}
<%_ if(filters.mongooseModels) { -%>
return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %>
return <%= classedName %>.findOneAndUpdate({_id: req.params.id}, req.body, {new: true, upsert: true, setDefaultsOnInsert: true, runValidators: true}).exec()<% } %>
<%_ if(filters.sequelizeModels) { -%>
return <%= classedName %>.upsert(req.body, {
where: {
Expand Down
6 changes: 3 additions & 3 deletions templates/endpoint/basename.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ describe('<%= classedName %> API:', function() {
updated<%= classedName %> = {};
});

it('should respond with the original <%= cameledName %>', function() {
<%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('New <%= classedName %>');
<%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the brand new <%= cameledName %>!!!');
it('should respond with the updated <%= cameledName %>', function() {
<%= expect() %>updated<%= classedName %>.name<%= to() %>.equal('Updated <%= classedName %>');
<%= expect() %>updated<%= classedName %>.info<%= to() %>.equal('This is the updated <%= cameledName %>!!!');
});

it('should respond with the updated <%= cameledName %> on a subsequent GET', function(done) {
Expand Down