美文网首页
ensureIndex() now is an alias fo

ensureIndex() now is an alias fo

作者: Yves_lau | 来源:发表于2015-10-15 17:47 被阅读365次

db.collection.ensureIndex()
Definition
db.collection.
ensureIndex
(
keys, options)

Deprecated since version 3.0.0: db.collection.ensureIndex()
is now an alias fordb.collection.createIndex()
.

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.

相关文章

网友评论

      本文标题:ensureIndex() now is an alias fo

      本文链接:https://www.haomeiwen.com/subject/lutacttx.html