Ensure Indexes before Each Save
- Rely on caching within the PyMongo driver to provide lightweight calls while indices are cached. - Closes MongoEngine/mongoengine#812.
This commit is contained in:
committed by
Matthew Ellison
parent
ff659a0be3
commit
db36d0a375
@@ -285,6 +285,8 @@ class Document(BaseDocument):
|
||||
|
||||
try:
|
||||
collection = self._get_collection()
|
||||
if self._meta.get('auto_create_index', True):
|
||||
self.ensure_indexes()
|
||||
if created:
|
||||
if force_insert:
|
||||
object_id = collection.insert(doc, **write_concern)
|
||||
|
||||
Reference in New Issue
Block a user