With the help of @ sqltools/formatter, it is reformed
npm install fmt-sqlGet the latest version from NPM/Yarn:
``shell`
npm install fmt-sql
#
yarn add fmt-sql
`ts
import sqlFormatter from 'fmt-sql';
console.log(sqlFormatter.format('SELECT * FROM table1'));
`
Will output:
``
SELECT *
FROM table1
You can also pass in configuration options:
`js`
sqlFormatter.format('SELECT *', {
language: 'sql',
indent: '\t', // Defaults to two spaces
});
| option | description | type | default |
| ------------------- | ------------------------------------------------ | ---------------------------------------------------------- | ------------------ |
| language | Query language, default is Standard SQL | sql, n1ql, db2, pl/sql | sql |string
| indent | Characters used for indentation | | (2 spaces) |upper
| reservedWordCase | How to change the case of reserved words | , lower, null | null (no change) |number
| linesBetweenQueries | How many line breaks between queries | or 'preserve' | 1 |object
| params | Collection of params for placeholder replacement | for name params, array` for indexed placeholders | |