简体   繁体   中英

How to remove a item inside a dictionary value use pymongo?

I want remove a item inside a dictionary value but i don't know how i many ways but I couldn't

{
  "_id": {
    "$oid": "63a7cd40c93763cb93fb27b4"
  },
  "-1001166788687": {
    "84653426": "<a href=tg://user?id=84653426>Returning</a>"
  },
  "group_name": "T"
}

I want remove this

"84653426": "<a href=tg://user?id=84653426>Returning</a>"

You can do it with $unset operator:

db.collection.update({
  "_id": "1"
},
{
  "$unset": {
    "-1001166788687.84653426": 1
  }
})

Working example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM