diff --git a/lib/railway.js b/lib/railway.js index d391c9be..172ba051 100644 --- a/lib/railway.js +++ b/lib/railway.js @@ -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; }; /** diff --git a/package.json b/package.json index 56c90d9e..06a5a7f6 100644 --- a/package.json +++ b/package.json @@ -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 ", "contributors": [ { "name": "Anatoliy Chakkaev", "email": "rpm1602@gmail.com" },