node.js - Mongo collection.update not removing element even though it returns 1 as the number of objects updated -
I am trying to remove the second segment from the object below. I have the What am I doing and how can I fix it? Example object update snippet Since I am using the monk library, Found from: section_id address
section object that I want to remove and returns the code given below 1 such as 1 record was deleted, but any
section Objects are actually removed.
{_id: 'asdfjklsfo' name: 'My name', section: [{section_id: 'ADLFSDF', & lt; - This is a real Mongo object title: 'my title'}, {section_id: 'asdflnmasdf', & lt; - This is a real Mongo object title: 'second title'}]}
var archive = db.get ('notes') ; (Error) if there was a problem deleting that note (mistake) {res.send ("" "" "" from the database. ");} And {console.log (num_modified); <- this 1 console Res.send (204);}}); It seems I had to do
collection.id (section_id) P>
collection .update ({_id: id}, {$ pull: {sections: {section_id : Collection.id (section_id)}}}, function (mistake, num_modified) {// If it is unsuccessful, return error (error) {res.send ("There was a problem deleting that note from the database. ");} Else {console.log (num_modified); & lt; - this 1 console.log ('success was deleted'); res.send (204);}});
Comments
Post a Comment