-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: MongoDB 3.2, MongoDB 3.4
The documentation of MongoDB states that `ensureIndex` should be deprecated, and an alias of `createIndex`:
db.collection.ensureIndex(keys, options)
Deprecated since version 3.0.0: db.collection.ensureIndex() is now an alias for db.collection.createIndex().
However, upon analysing the code, they seem to have clearly different functionality and `ensureIndex` does not in fact look like a simple alias for `createIndex`:
createIndex
https://github.com/mongodb/node-mongodb-native/blob/3.0.0/lib/db.js#L1029
ensureIndex
https://github.com/mongodb/node-mongodb-native/blob/3.0.0/lib/db.js#L1113
Expected behaviour is that in light of the deprecation, `ensureIndex` should simply call `createIndex`.
Currently there seem to be some users who still rely on the side effects present in `ensureIndex`, but they should probably receive a deprecation notice as well as instructions on how to migrate to using `createIndex` instead.