Answers for "mongoose delete number of objects from array in mongoose"

0

how to remove one object in an array of objects in mongoose

User.update( 
    { "_id" : userID} , 
    { "$pull" : { "teams" : { "_id" :  teamID } } } , 
    { "multi" : true }  
)
Posted by: Guest on May-31-2021
1

mongoose remove element from array

db.survey.update( // select your doc in moongo
    { }, // your query, usually match by _id
    { $pull: { results: { $elemMatch: { score: 8 , item: "B" } } } }, // item(s) to match from array you want to pull/remove
    { multi: true } // set this to true if you want to remove multiple elements.
)
Posted by: Guest on October-14-2020

Code answers related to "TypeScript"

Browse Popular Code Answers by Language