Wednesday 4 May 2016

createIndex(), getIndexes() & dropIndex() functions in mongoDB


Lecture Notes
As of mongodb 3.0, ensureIndex() is deprecated, though it will still work; you should use createIndex() instead. If you use ensureIndex with mongodb 3.0, it will point to createIndex.
Quiz: createIndex(), getIndexes() & dropIndex()
What will happen if an index is created on a field that does not exist in any of the documents in the collection?
1.MongoDB will throw an error and not create the index.
2.MongoDB will create the index but give a warning.
3.MongoDB will not create the index and not throw an error.
4.MongoDB will ask if you're sure first.
5.MongoDB will create the index without any warning.


Ans.


5.MongoDB will create the index without any warning.

No comments:

Post a Comment