🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

mongoose-hook-ensure-indexes

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-hook-ensure-indexes

A mongoose plugin, improving 'Model.ensureIndexes' method, allowing also deletion of unused indexes and reindexing with changed options.

0.1.4
latest
Source
npm
Version published
Maintainers
1
Created
Source

mongoose-hook-ensure-indexes

A mongoose plugin, improving 'Model.ensureIndexes' method, allowing also deletion of unused indexes and reindexing with changed options.

Installation

git clone git@github.com:tarquas/mongoose-hook-ensure-indexes.git mongoose-hook-ensure-indexes

Package

{
  "mongoose-hook-ensure-indexes": "0.1.4"
}

Usage

Example:

var
  mongoose = require('mongoose'),
  ensureIndexes = require('mongoose-hook-ensure-indexes'),
  PersonSchema;

PersonSchema = {
  name: String,
  email: String
};

PersonSchema.index({name: 1});
PersonSchema.index({email: 1}, {unique: true});

PersonSchema.plugin(ensureIndexes, {mongoose: mongoose});

mongoose.model('Person', PersonSchema);

Notes

  • This plugin must be provided with an exact instance of mongoose, where the processing models expected to be processed, in opts parameter.

  • This plugin makes sure that no other indexes persist on MongoDB collection than those, which specified in Schema. New indexes get created. Obsolete indexes get dropped. Indexes with changed options get recreated and rebuilt.

Keywords

mongoose

FAQs

Package last updated on 09 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts