How to delete an item from a list (ListField) by id in MongoEngine?

advertisements

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/tests/queryset.py#L1374

See $pull: http://www.mongodb.org/display/DOCS/Updating#Updating-%24pull