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:
Howard M. Lewis Ship 2014-10-07 14:43:19 -07:00
commit 6622c49b47

View file

@ -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"]
```
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:
```clj
@ -232,7 +268,6 @@ If you do implement a clause or function handler, consider submitting a pull req
## TODO
* Insert, update, delete
* Create table, etc.
## License