expand find-by-keys examples
This commit is contained in:
parent
06bdbd8139
commit
2b7f25ac78
3 changed files with 21 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ Only accretive/fixative changes will be made from now on.
|
||||||
|
|
||||||
* 1.3.next in progress
|
* 1.3.next in progress
|
||||||
* Address [#258](https://github.com/seancorfield/next-jdbc/issues/258) by updating all the library (driver) versions in Getting Started to match the latest versions being tested (from `deps.edn`).
|
* Address [#258](https://github.com/seancorfield/next-jdbc/issues/258) by updating all the library (driver) versions in Getting Started to match the latest versions being tested (from `deps.edn`).
|
||||||
|
* Expand examples for calling `next.jdbc.sql/find-by-keys` to show `LIKE` and `IN` clauses.
|
||||||
* Update `tools.build` to 0.9.6 (and get rid of `template/pom.xml` in favor of new `:pom-data` option to `b/write-pom`).
|
* Update `tools.build` to 0.9.6 (and get rid of `template/pom.xml` in favor of new `:pom-data` option to `b/write-pom`).
|
||||||
|
|
||||||
* 1.3.894 -- 2023-09-24
|
* 1.3.894 -- 2023-09-24
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
[:scm
|
[:scm
|
||||||
[:url "https://github.com/seancorfield/next-jdbc"]
|
[:url "https://github.com/seancorfield/next-jdbc"]
|
||||||
[:connection "scm:git:https://github.com/seancorfield/next-jdbc.git"]
|
[:connection "scm:git:https://github.com/seancorfield/next-jdbc.git"]
|
||||||
[:developerConnection "scm:git:ssh://git@github.com/seancorfield/next-jdbc.git"]
|
[:developerConnection "scm:git:ssh:git@github.com:seancorfield/next-jdbc.git"]
|
||||||
[:tag (str "v" version)]]])
|
[:tag (str "v" version)]]])
|
||||||
|
|
||||||
(defn- jar-opts [opts]
|
(defn- jar-opts [opts]
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,25 @@ Given a table name (as a keyword) and either a hash map of column names and valu
|
||||||
"Stella" "stella@artois.beer"])
|
"Stella" "stella@artois.beer"])
|
||||||
```
|
```
|
||||||
|
|
||||||
|
While the hash map approach -- "query by example" -- is great for equality
|
||||||
|
comparisons, sometimes you need other types of comparisons. For example, you
|
||||||
|
might want to find all the rows where the email address ends in `.beer`:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
(sql/find-by-keys ds :address ["email LIKE ?" "%.beer"])
|
||||||
|
;; equivalent to
|
||||||
|
(jdbc/execute! ds ["SELECT * FROM address WHERE email LIKE ?" "%.beer"])
|
||||||
|
```
|
||||||
|
|
||||||
|
Or you may want to find all the rows where the name is one of a specific
|
||||||
|
set of values:
|
||||||
|
|
||||||
|
```clojure
|
||||||
|
(sql/find-by-keys ds :address ["name IN (?,?)" "Stella" "Waldo"])
|
||||||
|
;; equivalent to
|
||||||
|
(jdbc/execute! ds ["SELECT * FROM address WHERE name IN (?,?)" "Stella" "Waldo"])
|
||||||
|
```
|
||||||
|
|
||||||
The default behavior is to return all the columns in each row. You can specify a subset of columns to return using the `:columns` option. It takes a vector and each element of the vector can be:
|
The default behavior is to return all the columns in each row. You can specify a subset of columns to return using the `:columns` option. It takes a vector and each element of the vector can be:
|
||||||
|
|
||||||
* a simple keyword representing the column name (`:column-fn` will be applied, if provided),
|
* a simple keyword representing the column name (`:column-fn` will be applied, if provided),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue