Support modular railway
This commit is contained in:
parent
7d748e9c02
commit
2b67400525
4
index.js
4
index.js
|
@ -5,10 +5,10 @@ exports.Schema = require('./lib/schema').Schema;
|
|||
exports.AbstractClass = require('./lib/abstract-class').AbstractClass;
|
||||
exports.Validatable = require('./lib/validatable').Validatable;
|
||||
|
||||
exports.init = function () {
|
||||
exports.init = function (root) {
|
||||
if (!global.railway) return;
|
||||
railway.orm = exports;
|
||||
require('./lib/railway');
|
||||
require('./lib/railway')(root);
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
@ -4,7 +4,9 @@ var Schema = railway.orm.Schema;
|
|||
|
||||
railway.orm._schemas = [];
|
||||
|
||||
var confFile = app.root + '/config/database.json';
|
||||
module.exports = function init(root) {
|
||||
|
||||
var confFile = (root || app.root) + '/config/database.json';
|
||||
var config;
|
||||
|
||||
if (path.existsSync(confFile)) {
|
||||
|
@ -25,7 +27,7 @@ railway.orm._schemas.push(schema);
|
|||
context = prepareContext(schema);
|
||||
|
||||
// run schema first
|
||||
var schemaFile = app.root + '/db/schema.';
|
||||
var schemaFile = (root || app.root) + '/db/schema.';
|
||||
if (path.existsSync(schemaFile + 'js')) {
|
||||
schemaFile += 'js';
|
||||
} else if (path.existsSync(schemaFile + 'coffee')) {
|
||||
|
@ -173,3 +175,5 @@ function prepareContext(defSchema, done) {
|
|||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue