Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Extra index functionality for mongoose
branch: master

Merge pull request #4 from Clever/test-multi-key-index

add test for multi-key indices
latest commit cb6430a06e
Daniel Fuentes dfuentes authored


Build Status

Mongoose plugin that adds some additional functionality to mongoose indexes:

  1. Lets you add arbitrary indexes to any path, regardless of whether it's specified in your schema. The typical case is when you want sparse indexes within a Mixed type:

    any_index = require 'mongoose-any-index'
    Awesome = new Schema
      email: { type: String, index: true, unique: true, required: true }
      tags: [{type: String}]
      data: { type: Schema.Types.Mixed }
    Awesome.plugin any_index, [
      { keys: { 'data.nested_field': 1 }, options: { unique: true, sparse: true } }
  2. Adds a Model.fullEnsureIndexes(cb) static method that drops indexes not specified in your schema. This lets you avoid "index bloat", since mongoose's Model.ensuresIndexes(cb) by default does not call dropIndex on pre-existing indexes.


npm install mongoose-any-index
Something went wrong with that request. Please try again.