June 2014
Intermediate to advanced
696 pages
38h 52m
English
You might want to assign indexes to specific fields that you frequently use to find documents. You can apply indexes to a schema object when defining the schema or by using the index(fields) command. For example, both of the following add an index to the name field, in ascending order:
var schema = new Schema({ name: {type: String, index: 1}};//orvar schema = new Schema({name: String)};schema.index({name:1});
You can get a list of indexed fields on a schema object by using the indexes() method. For example:
schema.indexes()
Read now
Unlock full access