Waterline model loader
Node module to load Waterline models from a directory and use the file names (without the extension) for the model names. It is an abstraction on the Waterline loading process.
Installation
npm install --save waterline-model-loader
Basic usage
Create a directory where your models live. The files are loaded recursively, however the name of the model files must be unique.
Model example:
// ./models/Example.js // A regular Waterline modelmoduleexports = attributes: name: type: 'string' required: true ;
Usage example:
const path = ;const modelLoader = default; let config = modelsDir: path connections: // Waterline connections object ; modelLoader; // Alternatively you can access the models from the modelLoader singleton after setup:// let models = modelLoader.models; // When quiting your app you can teardown the connections.// This could be necessary for tests if multiple connections are loaded.modelLoader
See the Waterline docs for a connections object or check the tests for an example.