Monday, 22 May 2017

Lodash - Merging two objects and removing properties which are not present from the original.

I've got a front-end app in which the user can add/remove fields from their profile. I'm trying to create a PUT request to the API and usually I'd just _.merge(original, req.body but the updated object has several properties removed from the object which is not on the original.

Is there any way to merge the objects and have the fields which are absent from the new object, also removed from the original one - while maintaining the original object (it's a mongoose model with id properties and such that I need to keep)

Thank you!



via makory

No comments:

Post a Comment