forked from 1602/jugglingdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
legacy-compound-init.js
56 lines (49 loc) · 1.41 KB
/
legacy-compound-init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
var loadSchema = require('./legacy-compound-schema-loader');
module.exports = function init(compound, Schema, AbstractClass) {
if (global.railway) {
global.railway.orm = exports;
} else {
compound.orm = {
Schema,
AbstractClass
};
if (compound.app.enabled('noeval schema')) {
compound.orm.schema = loadSchema(
Schema,
compound.root + '/db/schema',
compound.app.get('database'),
compound
);
if (compound.app.enabled('autoupdate')) {
compound.on('ready', function() {
compound.orm.schema.forEach(function(s) {
s.autoupdate();
if (s.backyard) {
s.backyard.autoupdate();
s.backyard.log = s.log;
}
});
});
}
return;
}
}
// legacy stuff
if (compound.version > '1.1.5-15') {
compound.on('after routes', initialize);
} else {
initialize();
}
function initialize() {
var railway = './lib/railway', init;
try {
init = require(railway);
} catch (e) {
console.log(e.stack);
}
if (init) {
init(compound);
}
}
};