0.2.8 • Published 8 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
8 years ago
0.2.7
8 years ago
0.2.6
8 years ago
0.2.5
8 years ago
0.2.4
9 years ago
0.2.3
9 years ago
0.2.2
9 years ago
0.2.1
9 years ago
0.2.0
9 years ago
0.1.9
9 years ago
0.1.8
9 years ago
0.1.7
10 years ago
0.1.6
10 years ago
0.1.5
10 years ago
0.1.4
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago