how to remove one object in an array of objects in mongoose
User.update(
{ "_id" : userID} ,
{ "$pull" : { "teams" : { "_id" : teamID } } } ,
{ "multi" : true }
)
how to remove one object in an array of objects in mongoose
User.update(
{ "_id" : userID} ,
{ "$pull" : { "teams" : { "_id" : teamID } } } ,
{ "multi" : true }
)
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.
)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us