ravel-sequelize-provider
Ravel Sequelize Provider
ravel-sequelize-provider
is a DatabaseProvider
for Ravel, wrapping the powerful node sequelize library. It supports connection pooling as well as Ravel's transaction system (including rollbacks).
Example usage:
Step 1: Import and instantiate the SequelizeProvider
app.js
const app = 'ravel';const SequelizeProvider = ;app; // load all model filesapp; // ... other providers and parametersapp;app;// ... the rest of your Ravel appapp;app;
app.getModel
Step 2: Access models via resources/posts_resource.js
const Ravel = ;const Resource = RavelResource;const transaction = Resourcetransaction; { super'/posts'; } /** * Retrieve a single post */ { // Best practice is to pass the transaction object through to a Module, where you handle the actual business logic. return thisapp; }
Step 3: Configuration
Requiring the ravel-sequelize-provider
module will register a configuration parameter with Ravel which must be supplied via .ravelrc
or app.set()
:
.ravelrc