Fork me on GitHub
Timofey Sitnikov01:06:49

@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.

Timofey Sitnikov01:06:54

@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 "")).

Timofey Sitnikov02:06:42

Actually, I looking through, 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 😐

Timofey Sitnikov02:06:58

@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 😎

😀 3

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)

Timofey Sitnikov02:06:45

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 ...