1.0.0 • Published 3 years ago

sails-hook-mongo-createindex v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

sails-hook-mongo-createindex

In a production environment, Sails.js does not create MongoDB index/unique indexes defined in the models, so you would have to do it manually.

This hook solve by using MongoDB's createIndex function to create the indexes.

Getting started

  1. Install the package
  2. Make sure you are using the sails-mongo database adapter
  3. Lift the app: sails lift

Usage

Just add unique or index to your model attribute.

attribute: {
    type: "string",
    index: true
}

or

attribute: {
    type: "string",
    unique: true
}

Contributions

If you find any bugs or want to improve the hook just open an issue or send a pull request, thanks!