sails-hook-mongoat
![Dependency Status](http://img.shields.io/david/teamfa/sails-hook-mongoat.svg?style=flat-square)
Provides advanced mongo indexing options for sails.js models that use the sails-mongo adapter.
Usage
npm i sails-hook-mongoat
Then simply add an 'indexes' array property to your sails model(s) that you want to add custom indexers on. This contains all your indexes.
Index properties:
- attributes - an object with the attributes to index (can also be text indexes)
- options (optional) - index options (see Mongo Index Options)
Examples
Creating a 'expires after' index
module.exports = {
attributes: {
myDate: {
type: 'date',
required: true
}
},
indexes: [
{
attributes: {
myDate: 1
},
options: {
expireAfterSeconds: 60
}
}
]
};
Creating a composite unique index
module.exports = {
attributes: {
event_id: {
type: 'integer',
required: true
},
match_id: {
type: 'integer',
required: true
}
},
indexes: [
{
attributes: {
event_id: -1,
match: 1
},
options: {
unique: true
}
}
]
};
Maintained By
![](http://i.imgur.com/NsAdNdJ.png)