Socket
Socket
Sign inDemoInstall

mongoose-hook-ensure-indexes

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-hook-ensure-indexes


Version published
Weekly downloads
1.7K
increased by72.98%
Maintainers
1
Created
Weekly downloads
 

Readme

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

FAQs

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc