Description
I just generated an endpoint with the generator and I'm getting some weird functionality on it, doing a PATCH request won't work at all and PUT does some weird stuff like it updates some field of other models.
I'm using an AngularJS $resource PUT request, for example my resource would look like this:
return $resource('/api/thing/:id', {id: '@_id'},{ 'update' : {method:'PATCH'} })
After that on the controller I would do:
this.thing.$update((data)=>{console.log(data)})
What I ended up doing was that I went back to the lodash approach instead of jsonpatch and it worked for me.
Instead of using the jsonPatch "PatchUpdates" function I'm using this one
function saveUpdates(updates) {
return function(entity) {
var updated = _.merge(entity, updates);
return updated.save()
.then(updated => {
return updated;
});
};
}
While this is working I'm wondering if the issue is with jsonpatch itself or otherwise, because I'm using the out of the box upsert function and it messes my other data, or is my understanding of upserting wrong?