Use const keyword to declare varibles

This commit is contained in:
Daniel García Aubert 2017-09-15 13:35:00 +02:00
parent b4ce13e429
commit ada58f6ea2

View File

@ -1,9 +1,27 @@
function BaseDataview() {} const FLOAT_OIDS = {
700: true,
701: true,
1700: true
};
module.exports = BaseDataview; const DATE_OIDS = {
1082: true,
1114: true,
1184: true
};
BaseDataview.prototype.getResult = function(psql, override, callback) { const columnTypeQueryTpl = ctx => `SELECT pg_typeof(${ctx.column})::oid FROM (${ctx.query}) _cdb_column_type limit 1`;
var self = this;
function getPGTypeName (pgType) {
return {
float: FLOAT_OIDS.hasOwnProperty(pgType),
date: DATE_OIDS.hasOwnProperty(pgType)
};
}
module.exports = class BaseDataview {
getResult (psql, override, callback) {
const self = this;
this.sql(psql, override, function(err, query) { this.sql(psql, override, function(err, query) {
if (err) { if (err) {
return callback(err); return callback(err);
@ -21,44 +39,23 @@ BaseDataview.prototype.getResult = function(psql, override, callback) {
}, true); // use read-only transaction }, true); // use read-only transaction
}); });
}
}; search (psql, userQuery, callback) {
BaseDataview.prototype.search = function(psql, userQuery, callback) {
return callback(null, this.format({ rows: [] })); return callback(null, this.format({ rows: [] }));
}; };
var FLOAT_OIDS = { getColumnType (psql, column, query, callback) {
700: true, const readOnlyTransaction = true;
701: true,
1700: true
};
var DATE_OIDS = { const columnTypeQuery = columnTypeQueryTpl({ column, query });
1082: true,
1114: true,
1184: true
};
var columnTypeQueryTpl = ctx => `SELECT pg_typeof(${ctx.column})::oid FROM (${ctx.query}) _cdb_column_type limit 1`;
BaseDataview.prototype.getColumnType = function (psql, column, query, callback) {
var readOnlyTransaction = true;
var columnTypeQuery = columnTypeQueryTpl({ column, query });
psql.query(columnTypeQuery, function(err, result) { psql.query(columnTypeQuery, function(err, result) {
if (err) { if (err) {
return callback(err); return callback(err);
} }
var pgType = result.rows[0].pg_typeof; const pgType = result.rows[0].pg_typeof;
callback(null, getPGTypeName(pgType)); callback(null, getPGTypeName(pgType));
}, readOnlyTransaction); }, readOnlyTransaction);
}
}; };
function getPGTypeName (pgType) {
return {
float: FLOAT_OIDS.hasOwnProperty(pgType),
date: DATE_OIDS.hasOwnProperty(pgType)
};
}