Merge pull request #22 from stathissideris/master
Just some updates to readme to reflect that insert, update and delete are implemented
This commit is contained in:
commit
6622c49b47
1 changed files with 36 additions and 1 deletions
37
README.md
37
README.md
|
|
@ -79,6 +79,42 @@ To add to clauses instead of replacing them, use `merge-select`, `merge-where`,
|
||||||
=> ["SELECT a, b, c, d, e FROM foo WHERE (f.a = ? AND b > 10)" "baz"]
|
=> ["SELECT a, b, c, d, e FROM foo WHERE (f.a = ? AND b > 10)" "baz"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Inserts are supported:
|
||||||
|
|
||||||
|
```clj
|
||||||
|
(-> (insert-into :properties)
|
||||||
|
(columns :name :surname :age)
|
||||||
|
(values
|
||||||
|
[["Jon" "Smith" 34]
|
||||||
|
["Andrew" "Cooper" 12]
|
||||||
|
["Jane" "Daniels" 56]])
|
||||||
|
sql/format)
|
||||||
|
=> ["INSERT INTO properties (name, surname, age)
|
||||||
|
VALUES (?, ?, 34), (?, ?, 12), (?, ?, 56)"
|
||||||
|
"Jon" "Smith" "Andrew" "Cooper" "Jane" "Daniels"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Updates are possible too (note the double S in `sset` to avoid clashing
|
||||||
|
with `clojure.core/set`):
|
||||||
|
|
||||||
|
```clj
|
||||||
|
(-> (update :films)
|
||||||
|
(sset {:kind "dramatic"
|
||||||
|
:watched true})
|
||||||
|
(where [:= :kind "drama"])
|
||||||
|
sql/format)
|
||||||
|
=> ["UPDATE films SET watched = TRUE, kind = ? WHERE kind = ?" "dramatic" "drama"]
|
||||||
|
```
|
||||||
|
|
||||||
|
Deletes look as you would expect:
|
||||||
|
|
||||||
|
```clj
|
||||||
|
(-> (delete-from :films)
|
||||||
|
(where [:<> :kind "musical"])
|
||||||
|
sql/format)
|
||||||
|
=> ["DELETE FROM films WHERE kind <> ?" "musical"]
|
||||||
|
```
|
||||||
|
|
||||||
Queries can be nested:
|
Queries can be nested:
|
||||||
|
|
||||||
```clj
|
```clj
|
||||||
|
|
@ -232,7 +268,6 @@ If you do implement a clause or function handler, consider submitting a pull req
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
* Insert, update, delete
|
|
||||||
* Create table, etc.
|
* Create table, etc.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue