This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-06
Channels
- # announcements (1)
- # atom-editor (2)
- # babashka (6)
- # beginners (30)
- # calva (12)
- # chlorine-clover (2)
- # clojure (88)
- # clojure-australia (2)
- # clojure-europe (9)
- # clojure-germany (4)
- # conjure (3)
- # cursive (12)
- # datomic (4)
- # lsp (86)
- # off-topic (48)
- # play-clj (8)
- # polylith (6)
- # reagent (11)
- # reitit (8)
- # shadow-cljs (19)
- # specter (6)
- # sql (13)
- # xtdb (25)
@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 "
.
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 😎
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 ...