Fork me on GitHub

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.


Thank you that worked!