Fix railway 1.0 support
This commit is contained in:
parent
8cee0ec9b2
commit
f7aed3a814
|
@ -9,16 +9,17 @@ if (global.railway) {
|
|||
}
|
||||
|
||||
module.exports = function init(root) {
|
||||
var railway, app;
|
||||
var railway, app, models;
|
||||
|
||||
if (typeof root !== 'object' || root.constructor.name !== 'Railway') {
|
||||
railway = global.railway;
|
||||
app = global.app;
|
||||
railway.models = app.models;
|
||||
models = app.models;
|
||||
} else {
|
||||
railway = root;
|
||||
app = railway.app;
|
||||
root = railway.root;
|
||||
models = railway.models;
|
||||
}
|
||||
|
||||
railway.orm._schemas = [];
|
||||
|
@ -80,8 +81,8 @@ railway.orm._schemas.forEach(function (schema) {
|
|||
// check validations and display warning
|
||||
|
||||
var displayWarning = false;
|
||||
Object.keys(railway.models).forEach(function (model) {
|
||||
var Model = railway.models[model];
|
||||
Object.keys(models).forEach(function (model) {
|
||||
var Model = models[model];
|
||||
if (Model._validations) {
|
||||
displayWarning = true;
|
||||
}
|
||||
|
@ -163,15 +164,15 @@ function prepareContext(railway, app, defSchema, done) {
|
|||
ctx.describe = ctx.define = function (className, callback) {
|
||||
var m;
|
||||
cname = className;
|
||||
models[cname] = {};
|
||||
_models[cname] = {};
|
||||
settings[cname] = {};
|
||||
if (nonJugglingSchema) {
|
||||
m = callback;
|
||||
} else {
|
||||
callback && callback();
|
||||
m = (schema || defSchema).define(className, models[cname], settings[cname]);
|
||||
m = (schema || defSchema).define(className, _models[cname], settings[cname]);
|
||||
}
|
||||
return railway.models[cname] = ctx[cname] = m;
|
||||
return models[cname] = ctx[cname] = m;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -184,7 +185,7 @@ function prepareContext(railway, app, defSchema, done) {
|
|||
type = String;
|
||||
}
|
||||
params.type = type || String;
|
||||
models[cname][name] = params;
|
||||
_models[cname][name] = params;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "jugglingdb",
|
||||
"description": "ORM for every database: redis, mysql, neo4j, mongodb, postgres, sqlite",
|
||||
"version": "0.1.24-pre2",
|
||||
"version": "0.1.26",
|
||||
"author": "Anatoliy Chakkaev <rpm1602@gmail.com>",
|
||||
"contributors": [
|
||||
{ "name": "Anatoliy Chakkaev", "email": "rpm1602@gmail.com" },
|
||||
|
|
Loading…
Reference in New Issue