Skip to content Skip to sidebar Skip to footer

Mongoengine Save Method Is Deprecated?

I wonder why my python says that mongoengine save() method is deprecated? I don't see any info about this into official documentation https://mongoengine.readthedocs.io/en/v0.9.0/a

Solution 1:

MongoEngine wraps PyMongo, which deprecated "save" in PyMongo 3.0:

http://api.mongodb.com/python/current/changelog.html#collection-changes

MongoEngine might need to deprecate its save method, or suppress the deprecation warning, or perhaps some other fix to handle this PyMongo change. I recommend you search MongoEngine's bug tracker and report this issue if it has not been already.

MongoEngine Bug - https://github.com/MongoEngine/mongoengine/issues/1491

Solution 2:

Using col.replace_one({‘_id': doc['_id']}, doc, True) instead.

The api is replace_one(filter, replacement, upsert=False, bypass_document_validation=False, collation=None, session=None).

Using upsert = True to insert a new doc if the filter find nothing.

Post a Comment for "Mongoengine Save Method Is Deprecated?"