Thursday, October 19, 2017

How to unset a field in Mongoose with findByIdAndUpdate [duplicate]

This question already has an answer here:

I use MEAN stack. On my backend I use findByIdAndUpdate function in Mongoose to do the update operation in CRUD. I also use Bootstrap UI date picker. On “clearing” of the date, uib-datepicker-popup resets the scope value for the date field to undefined. Now I pass the scope resource object into Mongoose with a HTTP PUT angular $resource call, it won’t pass the null properties in the json object. My date field is simply missing and unpopulated in the json object and PUTting out. Therefore The original date stays and I failed to reset the date field in the MongoDB document.

How should I approach deleting a certain field, then, as in unsetting with Mongoose built in “findByIdAndUpdate”?

Source: AngularJS



from Angular Questions https://angularquestions.com/2017/10/19/how-to-unset-a-field-in-mongoose-with-findbyidandupdate-duplicate/
via @lzomedia #developer #freelance #web #lzomedia.com

No comments:

Post a Comment