2016-11-07 16:31:34 +01:00

31 lines
734 B
JavaScript
Executable File

'use strict';
/**
* Module dependencies
*/
// Node.js core.
const fs = require('fs');
const path = require('path');
// Public node modules.
const _ = require('lodash');
/**
* Add options to a table
*/
module.exports = (models, modelName, value, option) => {
// Template: add a specific option.
// This is only called when we create a new table.
// The option's template is included in the
// `./builder/tables/createTableIfNotExists` template.
const tplOption = fs.readFileSync(path.resolve(__dirname, '..', '..', 'templates', 'builder', 'tables', 'options', option + '.template'), 'utf8');
models[modelName][option] = _.unescape(_.template(tplOption)({
tableName: modelName,
option,
value
}));
};