From 686106d544ecc3b6ffd4db2b665d3bc879a58d8c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 24 Sep 2012 16:22:07 -0400 Subject: ok --- node_modules/mongoose/docs/indexes.md | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 node_modules/mongoose/docs/indexes.md (limited to 'node_modules/mongoose/docs/indexes.md') diff --git a/node_modules/mongoose/docs/indexes.md b/node_modules/mongoose/docs/indexes.md new file mode 100644 index 0000000..f294318 --- /dev/null +++ b/node_modules/mongoose/docs/indexes.md @@ -0,0 +1,43 @@ + +Indexes +======= + +Indexes are defined through `ensureIndex` every time a model is compiled for a +certain connection / database. This means that indexes will only be ensured +once during the lifetime of your app. + +## Definition + +Regular indexes: + + var User = new Schema({ + name: { type: String, index: true } + }) + +[Sparse](http://www.mongodb.org/display/DOCS/Indexes#Indexes-SparseIndexes) indexes: + + var User = new Schema({ + name: { type: String, sparse: true } + }) + +Unique indexes: + + var User = new Schema({ + name: { type: String, unique: true } + }) + + // or + + var User = new Schema({ + name: { type: String, index: { unique: true } } + }) + +Unique sparse indexes: + + var User = new Schema({ + name: { type: String, unique: true, sparse: true } + }) + +Compound indexes are defined on the `Schema` itself. + + User.index({ first: 1, last: -1 }, { unique: true }) -- cgit v1.2.3-70-g09d2