Hi Ashwin Hariharan
Vikas Kumar
11

Hi Vikas,

Glad you liked the article. Yes, the code will skip the index creation if it already exists — in the older version of mongodb, it was ensureIndex for verifying if the index exists. Now this functionality has been added to the createIndex function, and ensureIndex is deprecated.

Also, check-out this answer on Stack Overflow.

And yes, you can always create multiple indexes on your collection.

Thank you for reading!

Like what you read? Give Ashwin Hariharan a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.