Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how create an index mongodb

db.collection.createIndex({age:1}) //single field asc index on age field
db.collection.createIndex({firstName:1,lastName:-1})//compound index on firstName asc and lastName desc
db.collection.createIndex({locations:1}) //given locations is an array then a multikey index will be created 
Source by docs.mongodb.com #
 
PREVIOUS NEXT
Tagged: #create #index #mongodb
ADD COMMENT
Topic
Name
6+5 =