knex-automigrate
Version:
Table schema based database migration tool, built on top of the knex.js
38 lines • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.innerBrackets = innerBrackets;
exports.multipleColumns = multipleColumns;
exports.firstQuoteValue = firstQuoteValue;
exports.isArrayEqual = isArrayEqual;
function innerBrackets(e) {
const begin = e.indexOf('(');
const end = e.lastIndexOf(')');
if (begin === -1 || end === -1 || begin >= end)
return null;
return e.slice(begin + 1, end);
}
function multipleColumns(e) {
if (!e)
return null;
return e.split(',').map((o) => {
let col = o;
if (col.slice(0, 1) === '`') {
col = col.slice(1);
if (col.indexOf('`') !== -1) {
col = col.slice(0, col.indexOf('`'));
}
}
return col.trim();
});
}
function firstQuoteValue(e) {
if (e.indexOf('`') === -1)
return null;
const s = e.slice(e.indexOf('`') + 1);
const closing = s.indexOf('`');
return closing === -1 ? s : s.slice(0, closing);
}
function isArrayEqual(a, b) {
return a.length === b.length && a.every((val, i) => val === b[i]);
}
//# sourceMappingURL=helper.js.map