As of the 3.0MongoDB version, ensureIndex()it has been deprecated in favor of createIndex()and is considered an alias of the latter:
In short, it doesn't make a difference if you're using the version 3.0, if you 're ensureIndex()actually using it you'd be calling createIndex()implicitly.
In the version 2.6of ensureIndex()what it did was to create the index on the specified field only if it did not exist previously.
The version 3.0of createIndex()creates the indexes on the collections .
As of the
3.0
MongoDB version,ensureIndex()
it has been deprecated in favor ofcreateIndex()
and is considered an alias of the latter:In short, it doesn't make a difference if you're using the version
3.0
, if you 'reensureIndex()
actually using it you'd be callingcreateIndex()
implicitly.In the version
2.6
ofensureIndex()
what it did was to create the index on the specified field only if it did not exist previously.The version
3.0
ofcreateIndex()
creates the indexes on the collections .