Produces static Sails / Waterline models by reverse engineering existing databases
npm install sails-model-reverserTo install this adapter, run:
``sh`
$ npm install --save sails-model-reverser
An example follows which uses the Apache Derby adapter (sails-derby) to
reverse engineer and create models for the TESTTABLE table of the TESTDB
database (running on the standard port of localhost).
Each model is written to a single file and is placed in the path specified
by options.outputPath (/path/for/output in the example below). If nogenerated
output path is specified, the files will be placed in the node_modules/sails-model-reverser/generated
sub-directory of this module (so, probably).
Each model is generated to use the connection specified by
options.connectionName (myConnection in the example below). If nodefault
connection name is specified, the default connection name, , will
be used.
At the time of this writing, sails-derby is the only tested adapter.
`javascript
var Reverser = require('sails-model-reverser');
var adapter = require('sails-derby');
var connection = {
url: 'jdbc:derby://localhost:1527/TESTDB',
minpoolsize: 10,
maxpoolsize: 100,
};
var tables = [
'TESTTABLE',
];
var options = {
outputPath: '/path/for/output',
connectionName: 'myConnection',
};
var reverser = new Reverser(adapter, connection, tables, options);
reverser.reverse();
``
- Stackoverflow
- #sailsjs on Freenode (IRC channel)
- Twitter
- Professional/enterprise
- Tutorials
-
MIT
© 2016 balderdashy & [contributors]
Mike McNeil, Balderdash & contributors
Sails is free and open-source under the MIT License.