autosql
Version:
An auto-parser of JSON into SQL.
26 lines (25 loc) • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isTime = exports.isDate = exports.isBoolean = exports.isText = exports.isFloating = exports.isInteger = exports.isNumeric = exports.groupings = void 0;
exports.groupings = {
"intGroup": ["boolean", "binary", "tinyint", "smallint", "int", "numeric", "bigint"],
"specialIntGroup": ["decimal", "double", "exponent"],
"textGroup": ["varchar", "text", "mediumtext", "longtext"],
"specialTextGroup": ["json"],
"dateGroup": ["date", "time", "datetime", "datetimetz", 'timestamp', 'timestamptz'],
"keysGroup": ["tinyint", "smallint", "int", "varchar"]
};
const isNumeric = (type) => ["tinyint", "smallint", "int", "bigint", "numeric", "decimal", "double", "exponent"].includes(type);
exports.isNumeric = isNumeric;
const isInteger = (type) => ["tinyint", "smallint", "int", "bigint"].includes(type);
exports.isInteger = isInteger;
const isFloating = (type) => ["numeric", "decimal", "double", "exponent"].includes(type);
exports.isFloating = isFloating;
const isText = (type) => ["varchar", "text", "mediumtext", "longtext", "json"].includes(type);
exports.isText = isText;
const isBoolean = (type) => type === "boolean";
exports.isBoolean = isBoolean;
const isDate = (type) => ["date", "datetime", "datetimetz"].includes(type);
exports.isDate = isDate;
const isTime = (type) => type === "time";
exports.isTime = isTime;