Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'parentapp'

  • Loading branch information...
commit 037dea6131ef57e58744fc4b35785dfd1284c25f 2 parents eab7737 + 6102256
@1602 authored
Showing with 24 additions and 19 deletions.
  1. +24 −19 lib/railway.js
View
43 lib/railway.js
@@ -26,29 +26,34 @@ module.exports = function init(root) {
var confFile = (root || app.root) + '/config/database';
var config = {};
-
- try {
- var cf = require(confFile);
- if (cf instanceof Array) cf = cf[0];
- if (typeof cs === 'function') {
- config = cs(railway);
- } else {
- config = cf[app.set('env')];
+ var schema;
+
+ if (!railway.parent) {
+ try {
+ var cf = require(confFile);
+ if (cf instanceof Array) cf = cf[0];
+ if (typeof cs === 'function') {
+ config = cs(railway);
+ } else {
+ config = cf[app.set('env')];
+ }
+ } catch (e) {
+ console.log('Could not load config/database.{js|json|yml}');
+ throw e;
}
- } catch (e) {
- console.log('Could not load config/database.{js|json|yml}');
- throw e;
- }
- // when driver name started with point - look for driver in app root (relative path)
- if (config.driver && config.driver.match(/^\./)) {
- config.driver = path.join(app.root, config.driver);
- }
+ // when driver name started with point - look for driver in app root (relative path)
+ if (config.driver && config.driver.match(/^\./)) {
+ config.driver = path.join(app.root, config.driver);
+ }
- var schema = new Schema(config && config.driver || 'memory', config);
- schema.log = log;
+ var schema = new Schema(config && config.driver || 'memory', config);
+ schema.log = log;
+ if (!schema.adapter) throw new Error('Adapter is not defined');
- if (!schema.adapter) throw new Error('Adapter is not defined');
+ } else {
+ schema = railway.parent.orm._schemas[0];
+ }
if (schema.waitForConnect) {
schema.on('connected', function() {
Please sign in to comment.
Something went wrong with that request. Please try again.