|
|
10 月之前 | |
|---|---|---|
| .. | ||
| lib | 10 月之前 | |
| typescript | 10 月之前 | |
| README.md | 10 月之前 | |
| package.json | 10 月之前 | |
Minifies PostgreSQL scripts, reducing the IO usage.
Features:
/*multi-line*/ (including nested) and --single-line comments/*!\nE where needed$ npm install pg-minify
const minify = require('pg-minify');
const sql = 'SELECT 1; -- comments';
minify(sql); //=> SELECT 1;
with compression (removes all unnecessary spaces):
const sql = 'SELECT * FROM "table" WHERE col = 123; -- comments';
minify(sql, {compress: true});
//=> SELECT*FROM"table"WHERE col=123;
The library's distribution includes TypeScript declarations.
SQLParsingError is thrown on failed SQL parsing:
try {
minify('SELECT \'1');
} catch (error) {
// error is minify.SQLParsingError instance
// error.message:
// Error parsing SQL at {line:1,col:8}: Unclosed text block.
}
Minifies SQL into a single line, according to the options.
Compresses / uglifies the SQL to its bare minimum, by removing all unnecessary spaces.
false (default) - keeps minimum spaces, for easier readtrue - removes all unnecessary spacesSee also: SQL Compression.
Removes everything, i.e. special/copyright multi-line comments that start with /*! will be removed as well.
Double-dollar $$ string escaping, which avoids escaping single quotes is not supported.
See issue #12.
Copyright © 2020 Vitaly Tomilov; Released under the MIT license.