This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-20
Channels
- # beginners (61)
- # cider (25)
- # cljsrn (7)
- # clojure (76)
- # clojure-austin (1)
- # clojure-russia (10)
- # clojure-uk (2)
- # clojurescript (96)
- # cursive (12)
- # datomic (38)
- # defnpodcast (9)
- # emacs (24)
- # fulcro (1)
- # graphql (5)
- # hoplon (3)
- # jobs (1)
- # keechma (20)
- # leiningen (4)
- # lumo (5)
- # off-topic (13)
- # perun (6)
- # re-frame (19)
- # reagent (1)
- # remote-jobs (2)
- # shadow-cljs (199)
- # sql (6)
- # vim (7)
I queried an object and assigned it to a variable called link-object
using the let macro but I’m not sure how access the columns in clojure. Here is a print out of the object from clojure: ({:id 2, :number 5 , :link_id 7, :account 30})
I tried this (get :number link-object)
The result of a query
is a sequence of hash maps. If you want the :number
from the first row: (:number (first link-object))
If you know the primary key of a row, you can use jdbc/get-by-id
to get a single row.
If you only want the first result from a query
, you can specify {:result-set-fn first}
as an option (the last argument).
Also, it'll help you get into the Clojure mindset @josmith2016 if instead of "assigned it to a variable" you think "bound the value to a symbol" -- because they're not really variables and you're not assigning to them.