From bd524d2e1e51f2c9ea4bc971003eeb34e8e7a090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Thu, 30 Aug 2018 23:13:10 +0200 Subject: [PATCH] Documented that it is possible to specify a name when using a dict to define an index --- docs/guide/defining-documents.rst | 3 +++ mongoengine/context_managers.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/guide/defining-documents.rst b/docs/guide/defining-documents.rst index 2a8d5418..366d12c7 100644 --- a/docs/guide/defining-documents.rst +++ b/docs/guide/defining-documents.rst @@ -513,6 +513,9 @@ If a dictionary is passed then the following options are available: Allows you to automatically expire data from a collection by setting the time in seconds to expire the a field. +:attr:`name` (Optional) + Allows you to specify a name for the index + .. note:: Inheritance adds extra fields indices see: :ref:`document-inheritance`. diff --git a/mongoengine/context_managers.py b/mongoengine/context_managers.py index ec2e9e8b..0343e163 100644 --- a/mongoengine/context_managers.py +++ b/mongoengine/context_managers.py @@ -215,7 +215,7 @@ class query_counter(object): """Get the number of queries.""" ignore_query = {'ns': {'$ne': '%s.system.indexes' % self.db.name}} count = self.db.system.profile.find(ignore_query).count() - self.counter - self.counter += 1 + self.counter += 1 # Account for the query we just fired return count