Remove a subdocument nested in an array in MongoDB

前端 未结 1 1327
萌比男神i
萌比男神i 2020-12-14 01:44

I want to remove this:

{
\"val\" : NumberLong(200),
\"chId\" : 2,
\"reqSys\" : \"222220005031\",
\"old\" : NumberL         


        
1条回答
  •  清歌不尽
    2020-12-14 02:31

    To remove sub document use $pull

    This query will remove from nested sub document

     db.collection.update({ d : 2014001 , m :123456789},
                          {$pull : { "topups.data" : {"val":NumberLong(200)} } } )
    

    0 讨论(0)
提交回复
热议问题