npm.io
1.0.0 • Published 10 years ago

sequelize-constants

Licence
MIT
Version
1.0.0
Deps
0
Vulns
0
Weekly
0
Stars
1

Sequelize constants plugin

Plugin allow to define constants in sequelize model

Usage


const sequelize = new Sequelize( credentials, options );

// Use plugin
require('sequelize-constants')( sequelize );

const MyModel = sequelize.define('MyModel', {
    /// Here cols defs
}, {
    constant: [
        STATUS_PENDING: 'pending',
        STATUS_RUNNING: 'running',
        STATUS_COMPLETE: 'complete',
        STATUS_ERROR: 'error',
        STATUS_ABORT: 'abort'
    ]
});

/// NOW access by

console.log( MyModel.STATUS_PENDING );

MyModel.STATUS_PENDING = 'foo'; // throw an error, readonly property!

Keywords