robbiblubber.org

help | login | search:  
<<

Home Page
Index

Projects

Utility Suite
Data Suite
Bad Wolf Suite
WeakWiki

User Docs

ConfigNotepad
LED
rqoon
Nuub

Code Docs

.NET
Java
PHP

robbiblubber.org

Specs
Articles

Sources















read  source  history 


createIndex()


MongoDB Driver Function Reference


Creates an index on the collection.
More information can be found in the corresponding entry of the MongoDB Manual.



<collection>.createIndex([<name>, ]<keys>[, <options>[, <commitQuorum>]])



Arguments


<collection> The target collection.
<name> Index name
<keys> A BSON document specifying the index keys.
<options> A BOSN document specifying options.
<commitQuorum> A string or integer specifying the commit quorum.



Options


{ unique: <boolean>, name: <string>, sparse: <boolean>, expireAfterSeconds: <long>, storageEngine: <document> }

unique Creates a unique index.
name Provides an index name.
sparse Index will only reference documents with the specified key.
expireAfterSeconds Index expiration time.
storageEngine Storage engine definition.




Example


db.employees.createIndex("salary_ix", { salary: 1 });


Creates an index for the salary key on the employees collection.




home | MongoDB Driver Function Reference | MongoDB Driver