Sunday 15 July 2012

python - Deleting EmbeddedDocument with FileField from ListField -


In Mongoengin, when removes an embedded document from a ListField that contains a FileField, the referenced file is not deleted. Currently, I have solved this problem by looping on the entire list field. For embodoc in doc.embdocs

 : if embdoc.filtered == value: embodoc.dfile.delete () doc.update (Pull__embdocs = {'filtered': value})   

I was thinking that there was a better way to do this.

By default, MongoDB does not check the integrity of your data, so by removing the documents Other documents still reference, which will lead to issues of sustainability.

You should use ListField with context field . reference fields can be used with the option reverse_delit_rooy = monoengine.plU or any other:

mongoigin.do_nothing It is the default and can be removed if nothing is done, but database inconsistencies or false information may be the reason.

Delete mongoengine.DENY has been rejected, if it is present in the context of deleted objects. > Mongoengin. Nullify Any object field referencing a deleted object is deleted (effectively using MongoDB). The relationship is rejected.

mongoengine.CASCADE Any object containing referencing fields for a deleted object is deleted first.

Drag the object (using the MongoDBâ € ™ s process) removing the reference from any object field of the list field (reference field) in the mongoengine.PULL field.

No comments:

Post a Comment