2016-11-18 8 views
1

私のユーザー・スキーマがマングースは

{ 
    widgets: [ 
    { 
     commands: [ 
     { 
      name: 'delete' 
     } 
     ] 
    } 
    ], 
    name: 'John', 
} 

あるネストされた配列を引くと、私はidでwidgets.commandsを削除したいです。私はマングースを使用します。私はIDを知っているが、私がプルリクエストをするときにそれを削除しない。 $pull: {widgets.$.commands: {_id: req.params.id}}提案がありますか?ここで

答えて

0

あなたは、doc

db.profiles.update({ _id: 1 }, { $pull: { votes: { $gte: 6 } } }) 
から

update({}, { 
    $pull: { 
     'widgets.commands._id': req.params.id, 
    }, 
}); 

$pull mongoDB documentation

@exampleを行きます