mkdir(dir_folder_controllers).then(() => { Models.map((model) => { var name_c = to .capitalize(model.model_name) .trim() .concat("Controller.js"); gencode.save(b.beautify_js(to.saveController(s.camelize(model.model_name))), dir_folder_controllers, name_c).then((value) => { bar2.tick(); if (bar2.complete) { console.log('Controllers ' + color("[OK]", "green")); } }, (err) => { console.warn([ansi.red.open, "ERROR", err, ansi.red.close].join("\n")); }); }); }, (ex) => { console.error(ex); });
createURL(host, port, database, function (err, connection_url) { if (err) return reject(err); var Models = []; mondongo .describe(connection_url) .then((described) => { described.forEach(elem => { if (elem.collection !== 'system.indexes' && elem.count > 0) { var attributes_sails = [], view_contents = []; elem .describe .forEach(item_descr => { var result = toSailsAttribute(item_descr.type, item_descr.key, item_descr.isID); attributes_sails.push(result.model_content); view_contents.push(result.view_content); }); Models.push({ model_name: s.camelize(elem.collection), content: "attributes: { " + (attributes_sails.join(", ")) + " }", view_content: view_contents }); } }); return resolve(Models); }); });
scanner.generate(pathsql, function(err, described) { if (err) { cb(err, null); } else { var Models = []; described.map((table, i) => { //console.log(table); var attributes_sails = [], view_contents = []; table.atr.map((attr) => { var transp = transpile(attr); attributes_sails.push(transp.model_content); view_contents.push(transp.view_content); }); Models.push({ model_name: s.camelize(table.table_name), content: "attributes: { " + (attributes_sails.join(", ")) + " }", view_content: view_contents }); }); cb(null, Models); } });
model_name:s.camelize(table).trim(), content: "attributes: { " + (attributes_sails.join(", ")) + " }", view_content: view_contents
model_name: s.camelize(table).trim(), content: "attributes: { " + attributes_sails + " }", view_content: view_contents