UNPKG

rapnc

Version:

Node client for RAP 1.0

62 lines (57 loc) 1.6 kB
function sql(sql, callback) { sequelize.query( sql, null, { raw: true }) .success(function(records) { callback(null, records); }) .fail(function(err) { callback(err); }); } function getSubParams(ids, array, callback) { sql('select a.complex_parameter_id, b.* from tb_complex_parameter_list_mapping a, tb_parameter b ' + ' where a.complex_parameter_id in (' + ids.join(',') + ') ' + ' and a.parameter_id = b.id ', function(err, params) { if (params.length == 0) { callback(null, array) } else { array = array.concat(params); var ids = getIds(params); if (!ids || ids.length == 0) { callback(null, array); } else { getSubParams(ids, array, callback); } } }) } function getIds(params) { var ids = []; params.forEach(function(p) { if (!p.data_type || !p.data_type.trim()) { return; } if (p.data_type.indexOf('object') == -1) { return; } ids.push(p.id); }); return ids; } function error(projectId, url) { if (!url) { url = ' found '; } else { url = ' (' + url + ') matched '; } return 'No action' + url + 'for PROJECT_ID: ' + projectId + ''; } function trim(url) { url = url.replace(/^\//g, ''); return url; } exports.trim = trim; exports.sql = sql; exports.getSubParams = getSubParams; exports.error = error; exports.getIds = getIds;