Package Exports
- sql-formatter
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sql-formatter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
SQL Formatter
SQL Formatter is a whitespace formatter for different query languages.
Installation
To install the newest version from NPM:
npm install --save sql-formatterThe SQL Formatter source code is written in ES2015 but we precompile both CommonJS and UMD builds to ES5 so they work in any modern browser.
If you don't use a module bundler then you can drop a file from /dist directory as a <script> tag on the page. The UMD builds make SQL Formatter available as a window.sqlFormatter global variable.
Example usage
First we need to import our CommonJS module and then we can use it for formatting standard SQL query.
import sqlFormatter from "sql-formatter";
const formattedStandardSql = sqlFormatter.format("sql", "SELECT * FROM table1");The value of formattedStandardSql will look like this:
SELECT
*
FROM
table1Supported languages
Standard SQL
sqlFormatter.format("sql", "SELECT * FROM table1 WHERE foo = bar");N1QL
sqlFormatter.format("n1ql", "SELECT fname, email FROM tutorial USE KEYS ['dave', 'ian'];");Contribute
TODO
Influence
SQL Formatter core logic is influenced by a PHP version of SQL Formatter by Jeremy Dorn.