diff --git a/README.md b/README.md index ebd697d..b28119d 100644 --- a/README.md +++ b/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"] ``` +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