structure:
{title: 'test', comments: [{id:1, title: ''}, {id: 8, title: ''}]}
i need remove the id=8 item, thanks.
Hi you can pull items from an array:
https://github.com/hmarr/mongoengine/blob/master/mongoengine/queryset.py
See $pull: http://www.mongodb.org/display/DOCS/Updating#Updating-%24pull
You need to use $pull operator here :
http://www.mongodb.org/display/DOCS/Updating#Updating-%24pull
db.collection.update({'title':'test'},{$pull : { 'comments' : { 'id' : 8 }});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With