Skip to content

Commit b6080d4

Browse files
committed
Improve readme
1 parent 6e03f63 commit b6080d4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

README.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ select "id" from "users"
325325

326326
## Advanced query methods
327327

328-
### .cursor()
328+
### Cursors
329329

330330
#### ```await sql``.cursor([rows = 1], [fn])```
331331

@@ -380,7 +380,7 @@ await sql`
380380
})
381381
```
382382
383-
### .forEach()
383+
### Instant iteration
384384
385385
#### ```await sql``.forEach(fn)```
386386
@@ -395,7 +395,7 @@ await sql`
395395
// No more rows
396396
```
397397
398-
### describe
398+
### Query Descriptions
399399
#### ```await sql``.describe([rows = 1], fn) -> Result[]```
400400
401401
Rather than executing a given query, `.describe` will return information utilized in the query process. This information can include the query identifier, column types, etc.
@@ -416,10 +416,10 @@ Using `.raw` will return rows as an array with `Buffer` values for each column,
416416
417417
This can be useful for specific performance/transformation reasons. The column definitions are still included on the result array, plus access to parsers for each column.
418418
419-
### File
419+
### Queries in Files
420420
#### `await sql.file(path, [args], [options]) -> Result[]`
421421
422-
Using a `.sql` file for a query is also supported with optional parameters to use if the file includes `$1, $2, etc`
422+
Using a file for a query is also supported with optional parameters to use if the file includes `$1, $2, etc`
423423
424424
```js
425425
const result = await sql.file('query.sql', ['Murray', 68])
@@ -527,9 +527,9 @@ Do note that you can often achieve the same result using [`WITH` queries (Common
527527
528528
## Data Transformation
529529
530-
`postgres.js` comes with a number of built-in data transformation functions that can be used to transform the data returned from a query or when inserting data. They are available under `transformation` option in the `postgres()` function connection options.
530+
Postgres.js comes with a number of built-in data transformation functions that can be used to transform the data returned from a query or when inserting data. They are available under `transform` option in the `postgres()` function connection options.
531531
532-
Like - `postgres('connectionURL', { transformation: {...} })`
532+
Like - `postgres('connectionURL', { transform: {...} })`
533533
534534
### Parameters
535535
* `to`: The function to transform the outgoing query column name to, i.e `SELECT ${ sql('aName') }` to `SELECT a_name` when using `postgres.toCamel`.
@@ -555,7 +555,7 @@ These functions can be passed in as options when calling `postgres()`. For examp
555555
})();
556556
```
557557
558-
> Note that if a column name is originally registered as snake_case in the database then to tranform it from camelCase to snake_case when querying or inserting, the column camelCase name must be put in `sql('columnName')` as it's done in the above example.
558+
> Note that if a column name is originally registered as snake_case in the database then to tranform it from camelCase to snake_case when querying or inserting, the column camelCase name must be put in `sql('columnName')` as it's done in the above example, Postgres.js does not rewrite anything inside the static parts of the tagged templates.
559559
560560
## Listen & notify
561561
@@ -686,6 +686,7 @@ const sql = postgres('postgres://username:password@host:port/database', {
686686
debug : fn, // Is called with (connection, query, params, types)
687687
socket : fn, // fn returning custom socket to use
688688
transform : {
689+
undefined : undefined, // Transforms undefined values (eg. to null)
689690
column : fn, // Transforms incoming column names
690691
value : fn, // Transforms incoming row values
691692
row : fn // Transforms entire rows
@@ -1006,4 +1007,4 @@ A really big thank you to [@JAForbes](https://twitter.com/jmsfbs) who introduced
10061007
10071008
Thanks to [@ACXgit](https://twitter.com/andreacoiutti) for initial tests and dogfooding.
10081009
1009-
Also thanks to [Ryan Dahl](http://github.com/ry) for letting me have the `postgres` npm package name.
1010+
Also thanks to [Ryan Dahl](https://github.com/ry) for letting me have the `postgres` npm package name.

0 commit comments

Comments
 (0)