What is the basic syntax to use index in mongodb?



What is the basic syntax to use index in mongodb?..

Answer / Rahul Bhatia

In MongoDB, creating an index can be done using the following syntax: `db.collection.createIndex( { field1: -1 } `. The `field1` refers to the field you want to index and the `-1` indicates ascending or descending order of the index (in this case, it is descending).

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MongoDB Interview Questions

When will data be on more than one shard?

1 Answers  


What is sharding in mongodb?

1 Answers  


Why does profiler use in mongodb?

1 Answers  


What are different between mongodb and sql server databases?

1 Answers  


What is schema mongodb?

1 Answers  


What query language does mongodb use?

1 Answers  


Is it possible to configure the cache size for mmapv1 in mongodb?

1 Answers  


What is orm mongodb?

1 Answers  


Does mongodb require a schema?

1 Answers  


Is mongodb stitch free?

1 Answers  


Mention the command syntax that is used to view mongo is using the link?

1 Answers  


Whether use to safe backup log feature in mongodb?

1 Answers  


Categories