You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-1Lines changed: 25 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,19 +24,22 @@ The query creation and usage is exactly the same as honeysql.
24
24
-[pattern matching](#pattern-matching)
25
25
-[except](#except)
26
26
-[filter](#filter)
27
+
-[within group](#within-group)
27
28
-[SQL functions](#sql-functions)
28
29
-[License](#license)
29
30
30
31
## Usage
31
32
32
33
### REPL
34
+
33
35
```clojure
34
36
(require '[honeysql.core :as sql]
35
37
'[honeysql.helpers :refer:all:as sqlh]
36
38
'[honeysql-postgres.helpers :as psqlh])
37
39
```
38
40
39
41
### distinct-on
42
+
40
43
`select` can be written with a `distinct on` clause
41
44
```clojure
42
45
(-> (select:column-1:column-2:column-3)
@@ -47,6 +50,7 @@ The query creation and usage is exactly the same as honeysql.
47
50
```
48
51
49
52
### upsert
53
+
50
54
`upsert` can be written either way. You can make use of `do-update-set!` over `do-update-set`, if you want to modify the some column values in case of conflicts.
51
55
```clojure
52
56
(-> (insert-into:distributors)
@@ -69,6 +73,7 @@ The query creation and usage is exactly the same as honeysql.
69
73
```
70
74
71
75
### insert into with alias
76
+
72
77
`insert-into-as` can be used to write insert statements with table name aliased.
73
78
```clojure
74
79
(-> (psqlh/insert-into-as:distributors:d)
@@ -84,6 +89,7 @@ The query creation and usage is exactly the same as honeysql.
84
89
```
85
90
86
91
### over
92
+
87
93
You can make use of `over` to write window functions where it takes in vectors with aggregator functions and window functions along with optional alias like `(over [aggregator-function window-function alias])`, the can be coupled with the `window` clause to write window-function functions with alias that is later defines the window-function, like `(-> (over [aggregator-function :w]) (window :w window-function))`.
88
94
```clojure
89
95
(-> (select:id)
@@ -108,6 +114,7 @@ You can make use of `over` to write window functions where it takes in vectors w
108
114
```
109
115
110
116
### create table
117
+
111
118
`create-table` and `with-columns` can be used to create tables along with the SQL functions, where `create-table` takes a table name as argument and `with-columns` takes a vector of vectors as argument, where the vectors describe the column properties as `[:column-name :datatype :constraints ... ]`.
112
119
```clojure
113
120
(-> (psqlh/create-table:films)
@@ -122,13 +129,15 @@ You can make use of `over` to write window functions where it takes in vectors w
0 commit comments