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 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.

What am I doing and how can I fix it?

Example object

  {_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'}]}   

update snippet

  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> 
like this:
  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);}});   

Since I am using the monk library, Found from:

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -