您的当前位置:首页正文

ensureIndex() now is an alias fo

来源:华拓网

Creates an index on the specified field if the index does not already exist.

But in pymongo :
Unlike :meth:`create_index`, which attempts to create an index unconditionally, :meth:`ensure_index` takes advantage of some caching within the driver such that it only attempts to create indexes that might not already exist. When an index is created (or ensured) by PyMongo it is "remembered" for `cache_for` seconds. Repeated calls to :meth:`ensure_index` within that time limit will be lightweight - they will not attempt to actually create the index.