0.2.8 • Published 7 years ago
waterline-model-loader v0.2.8
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 model
module.exports = {
attributes: {
name: {
type: 'string',
required: true
}
}
};
Usage example:
const path = require('path');
const modelLoader = require('waterline-model-loader').default;
let config = {
modelsDir: path.join(__dirname, './models'),
connections: {
// Waterline connections object
}
};
modelLoader.setup(config).then(models => {
// do stuff with your Waterline models
let ExampleModel = models.Example;
// do stuff with ExampleModel
}).catch(err => {
// deal with any setup errors
});
// 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.teardown().then(() => {
console.log('done');
}).catch(err => {
// deal with an error (and report it if you suspect a bug)
})
See the Waterline docs for a connections object or check the tests for an example.
0.2.8
7 years ago
0.2.7
7 years ago
0.2.6
7 years ago
0.2.5
7 years ago
0.2.4
7 years ago
0.2.3
7 years ago
0.2.2
8 years ago
0.2.1
8 years ago
0.2.0
8 years ago
0.1.9
8 years ago
0.1.8
8 years ago
0.1.7
8 years ago
0.1.6
8 years ago
0.1.5
8 years ago
0.1.4
8 years ago
0.1.3
8 years ago
0.1.2
8 years ago
0.1.1
8 years ago
0.1.0
8 years ago