Skip to content

Commit b3509cc

Browse files
author
Uku Pattak
committed
Merge branch 'master' of github.com:zeroturnaround/sql-formatter
2 parents 9bea08c + 0f92e37 commit b3509cc

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ npm install --save sql-formatter
1717

1818
The 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.
1919

20-
If you don't use a module bundler then you can drop a file from `/dist` directory as a `<script>` tag on the page. This makes SQL Formatter available as a `window.SqlFormatter` global variable.
20+
If you don't use a module bundler then you can drop a file from `/dist` directory as a `<script>` tag on the page. This makes SQL Formatter available as a `window.sqlFormatter` global variable.
2121

2222
## Example usage
2323

2424
First we need to import our CommonJS module and then we can use it for formatting
2525
standard SQL query.
2626

2727
```js
28-
import SqlFormatter from "sql-formatter";
28+
import sqlFormatter from "sql-formatter";
2929

30-
const formattedStandardSql = new SqlFormatter().format("sql", "SELECT * FROM table1");
30+
const formattedStandardSql = sqlFormatter.format("SELECT * FROM table1");
3131
```
3232

3333
The value of `formattedStandardSql` will look like this:
@@ -44,21 +44,26 @@ FROM
4444
### [Standard SQL](https://en.wikipedia.org/wiki/SQL:2011)
4545

4646
```js
47-
new SqlFormatter().format("sql", "SELECT * FROM table1 WHERE foo = bar");
47+
sqlFormatter.format("SELECT * FROM table1 WHERE foo = bar");
4848
```
4949

5050
### [N1QL](http://www.couchbase.com/n1ql)
5151

5252
```js
53-
new SqlFormatter().format("n1ql", "SELECT fname, email FROM tutorial USE KEYS ['dave', 'ian'];");
53+
sqlFormatter.format("SELECT fname, email FROM tutorial USE KEYS ['dave', 'ian'];", {language: "n1ql"});
5454
```
5555

5656
## Optional configuration
5757

58+
Example below has default values.
59+
5860
```js
59-
new SqlFormatter({
61+
const cfg = {
62+
language: "sql" // Specific query language
6063
indent: " " // Value that is used for creating indentation levels
61-
});
64+
};
65+
66+
sqlFormatter.format("SELECT *", cfg);
6267
```
6368

6469
## Contribute

0 commit comments

Comments
 (0)