mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Modifying document without uploading to the database

Open cyrlop opened this issue 4 years ago • 1 comments

Is there a way to update a document without uploading it to the database? The ultimate goal is to perform validation before uploading to the database (see #1984 and #1287).

I would like to do something like this:

document.modify(upload_to_db=False, **update) # or .upload()
document.validate()
document.save()

# or 

document.modify(upload_to_db=False, **update) # or .upload()
document.save(validate=True)

How to get the updated document without upload? Recreating the new document is very painful while supporting the "Django-style update keyword arguments".

The only solution I have so far is to call modify() to get the new document, validate the document, re-upload the old document if the validation fails.

cyrlop avatar Aug 13 '21 07:08 cyrlop

I think this feature should be implemented in mongoengine

0xdia avatar Jan 01 '22 21:01 0xdia