Answers for "remove mongoose array data"

1

mongoose remove document from array

//db.collection.findOneAndUpdate( filter, update, options )
//{ $pull: { <field1>: <value|condition>} }

List.findOneAndUpdate({ name: listName }, { $pull: { <field1>: <value|condition> } }, function(err, foundList) {
    if (!err) {
         //your code
     }
}); //Here List is my collection name

//By Reacto Kalyan
Posted by: Guest on June-18-2021
0

mongoose delete object from array

doc.subdocs.push({ _id: 4815162342 }) // added
doc.subdocs.pull({ _id: 4815162342 }) // removed
Posted by: Guest on April-03-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language