Pomegranate-sequelize-core
Adds Sequelize as a merge plugin in the core Pomegranate load layer.
If you are not planning on writing your own model loader, consider using one of these plugins that include pomegranate-sequelize-core
- pomegranate-sequelize-pg
- all other sequelize supported DBs to come.
Install
Simply
npm install --save pomegranate-sequelize-core
Pomegranate will automatically load it up and provide
an injectable object named SQL
with the structure
{Sequelize: //Sequelize Object}
.
Usage
pomegranate-sequelize-core
is a Pomegranate merge plugin, that allows other plugins loaded in later layers to add properties to the object it adds to the dependency injector. The common usage would be to add a plugin to the Pomegranate data
layer, instantiate Sequelize, load your models into an object, then provide that object to the Pomegranate plugin load function.
exportsmetadata = name: 'MySequelizeImplementation' layer: 'data' // data or higher param: 'SQL' // must match type: 'merge' // merge the results into the existing object exportsplugin = { var Sequelize = thissequelize = //connection) // Find and load your models. var models = // add your models object to the SQL injectable ; } { // Call authentication etc. thissequelize } { thissequelize }}