DBCollection.ensureIndex()
was deprecated in version 2.12 and removed in version 3.0. DBCollection.createIndex()
is the one that should be used.It was used to create indexes on collections whereas
ensureIndex()
creates an index on the specified field if the index does not already exist. Moreover, when we execute createIndex()
twice the second execution will just fail whereas with ensureIndex()
you can invoke it multiple times and it will not fail
No comments:
Post a Comment