UNPKG

compound-ex4

Version:

Compound-ex4 - MVC framework for NodeJS (ExpressJs 4 version), fork compoundjs(https://github.com/1602/compound)

30 lines (25 loc) 750 B
// Deps var fs = require('fs'); var path = require('path'); /** * Initialize models with validations and implementation * * @param {Compound} compound - compound app. */ module.exports = function loadModels(compound, root) { if (!compound.structure.models) { return; } Object.keys(compound.structure.models).forEach(function (model) { var md = compound.structure.models[model]; var foundModel = compound.model(model); if (foundModel && foundModel._validations) { delete foundModel._validations; } if (typeof md === 'function') { md(compound, foundModel); } else { // rw.models[md.name || md.modelName || model] = md; } }); };