@seancorfield, as far as the docs I blame my beginner'ish status. But for me, that example makes it super clear, after seeing the example the docs make sense.
OK, cool. I will probably add an explicit example of use.
The idiomatic approach for keys with next.jdbc
is qualified keywords, per the documentation and the default behavior.
@seancorfield, I figured it out and I felt stupid so I deleted the question. Basically, I just needed to get the first
then the (:account/password (first (account/get-account-by-email "<mailto:tony@example.com|tony@example.com>"))
.
Actually, I looking through https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.2.659/doc/getting-started, wow, I can provide the {:builder-fn rs/as-unqualified-lower-maps} then I get the simples map.
If you only want one row, use execute-one!
(that's discussed in Getting Started).
Please try to work with the default and get used to qualified keywords first.
I wish more Clojurians would use qualified keys in maps 😐
@seancorfield, OK, so the most idiomatic approach is to use qualified keys, that is the answer I have been looking for, I just need to take the (first ...
of the vectors since I like the find-by-keys
query 😎
I tried it, but kept on scratching my head why it did not work and I could not find the function, now I know, need to use the development branch. 😂
Ah, yes, if you're using find-by-keys
, the assumption is you'll get a sequence of rows.
For the example you gave above, you could use destructuring to get at the password in a simple binding:
(let [[{:account/keys [password]}] (sql/find-by-keys ...)]
... password ..)
(and it'll be nil
if no rows matched)
Ahhhh, destucturing, I am having a hard time getting used to it, one day I will get it. Seems magical 🪄. I am also trying to get comfortable with using db as immutable db, its hard to break bad habits ...
If you're using the CLI and deps.edn
, you can rely on :git/url
versions so you can test it direct from source.