8000 Documentation update · alaisi/postgres.async@3a186ce · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a186ce

Browse files
committed
Documentation update
1 parent 1f06f16 commit 3a186ce

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The connection pool is closed with `close-db!`. This closes all open connections
3535

3636
Queries are executed with callback-based functions `query!` `insert!` `update!` `execute!` and [`core.async`](https://github.com/clojure/core.async) channel-based functions `<query!` `<insert!` `<update!` `<execute!`.
3737

38-
Channel-based functions return a channel where query result is put in vector of `[result-set exception]`.
38+
Channel-based functions return a channel where query result or exception is put.
3939

4040
### execute! and query!
4141

@@ -49,20 +49,20 @@ All other query functions delegate to `execute!`. This takes a db, a vector of s
4949

5050
;; async channel
5151
(<!! (<execute! db ["select name, price from products where id = $1" 1001]))
52-
; [{:updated 0, :rows [{:id 1001, :name "hammer", :price 10]]} nil]
52+
; {:updated 0, :rows [{:id 1001, :name "hammer", :price 10}]}
5353

5454
(<!! (<execute! db ["select * from foobar"]))
55-
; [nil #<SqlException com.github.pgasync.SqlException: ERROR: SQLSTATE=42P01, MESSAGE=relation "foobar" does not exist>
55+
; #<SqlException com.github.pgasync.SqlException: ERROR: SQLSTATE=42P01, MESSAGE=relation "foobar" does not exist>
5656
```
5757

5858
`query!` passes only `:rows` to callback.
5959

6060
```clojure
6161
(<!! (<query! db ["select name, price from products"]))
62-
; [[{:id 1000, :name "screwdriver", :price 15} {:id 1001, :name "hammer", :price 10] nil]
62+
; [{:id 1000, :name "screwdriver", :price 15} {:id 1001, :name "hammer", :price 10}]
6363

6464
(<!! (<query! db ["select name, price from products where id = $1" 1001]))
65-
; [[{:id 1001, :name "hammer", :price 10] nil]
65+
; [{:id 1001, :name "hammer", :price 10}]
6666
```
6767

6868
### insert!
@@ -71,10 +71,10 @@ Insert is executed with an sql-spec that supports keys `:table` and `:returning`
7171

7272
```clojure
7373
(<!! (<insert! db {:table "products"} {:name "screwdriver" :price 15}))
74-
; [{:updated 1, :rows []} nil]
74+
; {:updated 1, :rows []}
7575

7676
(<!! (<insert! db {:table "products" :returning "id"} {:name "hammer" :price 5}))
77-
; [{:updated 1, :rows [{:id 1001}]} nil]
77+
; {:updated 1, :rows [{:id 1001}]}
7878
```
7979

8080
Multiple rows can be inserted by passing a sequence to `insert!`.
@@ -83,7 +83,7 @@ Multiple rows can be inserted by passing a sequence to `insert!`.
8383
(<!! (<insert! db {:table "products" :returning "id"}
8484
[{:name "hammer" :price 5}
8585
{:name "nail" :price 1}]))
86-
; [{:updated 2, :rows [{:id 1001} {:id 1002]} nil]
86+
; {:updated 2, :rows [{:id 1001} {:id 1002}]}
8787
```
8888

8989
### update!
@@ -92,7 +92,7 @@ Update is executed with an sql-spec that supports keys `:table` `:returning` and
9292

9393
```clojure
9494
(<!! (<update! db {:table "users" :where ["id = $1" 1001}} {:price 6}))
95-
; [{:updated 1, :rows []} nil]
95+
; {:updated 1, :rows []}
9696
```
9797

9898
## Transactions
@@ -113,7 +113,7 @@ Channel-returning functions can be composed with `dosql` macro that returns `[re
113113
rs (<query! tx ["select * from promotions"])
114114
_ (<commit! tx)]
115115
{:now-promoting rs})))
116-
; [{:now-promoting [{:id 1, product_id 1002}]} nil]
116+
; {:now-promoting [{:id 1, product_id 1002}]}
117117
```
118118

119119
## Custom column types

0 commit comments

Comments
 (0)
0