UNPKG

749 BJavaScriptView Raw
1// Deps
2var fs = require('fs'),
3 path = require('path');
4
5/**
6 * Initialize models with validations and implementation
7 *
8 * @param {Compound} compound - compound app.
9 */
10module.exports = function loadModels(compound, root) {
11 if (!compound.structure.models) {
12 return;
13 }
14
15 Object.keys(compound.structure.models).forEach(function(model) {
16 var md = compound.structure.models[model];
17 var foundModel = compound.model(model);
18 if (foundModel && foundModel._validations) {
19 delete foundModel._validations;
20 }
21 if (typeof md === 'function') {
22 md(compound, foundModel);
23 } else {
24 // rw.models[md.name || md.modelName || model] = md;
25 }
26 });
27
28};
29