This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-16
Channels
- # announcements (5)
- # aws (34)
- # beginners (145)
- # cider (48)
- # circleci (8)
- # clara (7)
- # clj-kondo (28)
- # cljs-dev (75)
- # cljsrn (4)
- # clojure (325)
- # clojure-czech (10)
- # clojure-europe (5)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-spec (6)
- # clojure-sweden (3)
- # clojure-uk (70)
- # clojurescript (18)
- # clr (1)
- # community-development (2)
- # cursive (38)
- # data-science (7)
- # datascript (14)
- # datomic (22)
- # emacs (2)
- # figwheel (1)
- # fulcro (6)
- # graalvm (22)
- # graphql (11)
- # hoplon (12)
- # jackdaw (8)
- # jobs-discuss (16)
- # juxt (5)
- # leiningen (19)
- # luminus (5)
- # nrepl (2)
- # nyc (1)
- # off-topic (6)
- # overtone (2)
- # pedestal (10)
- # re-frame (6)
- # reagent (8)
- # reitit (1)
- # rewrite-clj (43)
- # ring (2)
- # shadow-cljs (124)
- # testing (1)
- # vim (22)
- # xtdb (77)
- # yada (4)
Is there a way to do nested transactions, for example, i want to add several bank accounts for a customer and then put their :db/ids in the customer/accounts (cardinality many attribute).
I think you’d generally use temporary ids for this:
[{:db/id "a1" :account/name "A1"}
{:db/id "a2" :account/name "A2"}
{:customer/accounts ["a1 "a1"]}]
I was thinking that, but the issue is that I don't know the number of accounts in advance. I know how to craft this, but I was looking for a more elegant way…
Accumulate the accounts in a set alongside the txn you’re building and then conj the customer accounts op onto the txn?
I think it is whatever position you have $ at in your :in
Or … looking through my own code, I appear to have it both as last and as first argument, which coincides with where the $
is in the :in
correct; if :in
is not explicit, it's assumed to be [$]
and you may supply a db as the only arg. If :in
is explicit then arg order corresponds to whatever :in
says, you can put db anywhere. $
must be the name of the magic implicit db though
Not sure if it's absolutely necessary, but at least strong convention dictates all db names should start with $
also
With a peer-server, how can i make it reconnect after deleting and re-creating the database without killing the process?
I am having a problem with a Datomic Cloud transaction function. Here's the function:
(defn xact-coll
"Transaction function that commits a collection, then puts the entities
of the collection into attr"
[db coll attr1 k attr2]
(let [m (into [] (map-indexed #(assoc %2 :db/id (str %1)) coll))
c (assoc {}
attr1 k
attr2 (into [] (map #(str %) (range (count coll)))))]
(concat m [c])))
and here's the invocation:
(defn save-funding-sources [customer-url funding-source-coll]
(let [coll (remove-nil-keywords funding-source-coll)
tx-data ['(stackz.db/xact-coll
coll
:customer/url customer-url
:customer/funding-sources)]]
(d/transact (schema/get-connection) {:tx-data tx-data})))
And here's the error message: ExceptionInfo Don't know how to create ISeq from: clojure.lang.Symbol clojure.core/ex-info (core.clj:4739)
I fixed this problem, now I'm getting
ExceptionInfo tempid used only as value in transaction clojure.core/ex-info (core.clj:4739)
How do I refer to an entity id in the same transaction?that error means you have a tempid on the right hand side somewhere, without any attributes on it
the problem here is you have an assertion like [:db/add 123 :attr "value"] without any other use of "value"
in the "e" slot
If you look at the transaction function, I am using the tempids as values to a cardinality many attribute. Do I have to break it up into two separate transactions?
I thought that the :db/id values in the collection were on the left-hand side, then they would be on the right-hand side when I am putting them into :customer/funding-sources.
Datomic Cloud 4777-8741 now available. https://forum.datomic.com/t/datomic-cloud-477-8741-http-direct-ion-0-9-34-and-ion-dev-0-9-229/982