This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-31
Channels
- # announcements (4)
- # aws-lambda (1)
- # babashka (25)
- # beginners (60)
- # calva (33)
- # cider (15)
- # cljdoc (1)
- # clojure (28)
- # clojure-dev (1)
- # clojure-europe (4)
- # clojurescript (29)
- # clojureverse-ops (4)
- # conjure (10)
- # datomic (4)
- # graalvm (4)
- # holy-lambda (4)
- # honeysql (13)
- # introduce-yourself (1)
- # lambdaisland (1)
- # missionary (11)
- # music (2)
- # off-topic (35)
- # pathom (17)
- # pedestal (20)
- # reagent (3)
- # sci (10)
- # shadow-cljs (39)
- # sql (6)
- # tools-deps (6)
- # vim (1)
Is there a straightforward way to do the following in one shot:
(let [{::jdbc/keys [datasource]} (system/system) ;A jdbc datasource is in the map
{:keys [address_id] :as person} {:first_name "Sherlock"
:last_name "Holmes"
:address_id {:street "Baker"}}
{:keys [ADDRESSES/ID]} (sql/insert! datasource "ADDRESSES" address_id)]
(sql/insert! datasource "PERSONS" (assoc person :address_id ID)))
The PERSONS table has an ADDRESS_ID column that is a FK to the ID column in the ADDRESSES table.(let [{::jdbc/keys [datasource]} (system/system)
(jdbc/with-transaction [t datasource] ... rest of your code, but use t instead ...))
Perfect, that is exactly what I was looking for. Thanks!