This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-14
Channels
- # aleph (10)
- # announcements (2)
- # beginners (228)
- # calva (18)
- # cider (6)
- # clara (5)
- # cljdoc (25)
- # cljs-dev (22)
- # clojure (78)
- # clojure-dev (30)
- # clojure-europe (2)
- # clojure-finland (1)
- # clojure-italy (32)
- # clojure-nl (21)
- # clojure-uk (126)
- # clojurescript (34)
- # cursive (5)
- # data-science (2)
- # datascript (2)
- # datomic (26)
- # defnpodcast (1)
- # emacs (5)
- # figwheel (5)
- # figwheel-main (3)
- # fulcro (14)
- # graphql (5)
- # jobs (1)
- # keechma (4)
- # nrepl (5)
- # off-topic (35)
- # onyx (3)
- # pedestal (12)
- # random (1)
- # re-frame (35)
- # reagent (8)
- # reitit (20)
- # remote-jobs (5)
- # ring-swagger (20)
- # shadow-cljs (166)
- # sql (43)
- # vim (6)
- # yada (15)
there’s no way to forward-declare an entity ref, right? i can’t tx data into a db like {:foo/bar [:bar/id 123]}
where bar/id
(and the associated entity) don’t yet exist in the db?
@lwhorton ^ however, if you are using a lookup ref then yes, the entity needs to exist already
@lwhorton see https://docs.datomic.com/cloud/transactions/transaction-data-reference.html#sec-7-1 about referencing other entities created within the same transaction
:thumbsup: i just ran some experiments with this and bumped into the “entity [ref val] doesn’t exist” problem
i've been using val
(from your above example) as a tempid when I know it's unique within a transaction and linking that way.
yea, i’m going to have a tiny ETL process that xforms external data into tx-data with using “tempids” that are really external foreign keys. the problem right now is just tracing my schema’s refs so i can ensure correct import order (and avoid trying to lookup-ref some entity that doesnt yet exist)
Is there a dictionary of Datomic errors? This one is currently inscrutable to me:
{
"Type": "clojure.lang.ExceptionInfo",
"Message": "Server Error",
"Data": {
"CognitectAnomaliesCategory": "CognitectAnomaliesFault",
"CognitectAnomaliesMessage": "Server Error",
"DatomicAnomaliesError": {
"Error": "Unable to create catalog entry",
"Cause": {
"Conflict": true
}
}
}
Is this a user-level issue? (e.g., attempting to transact tx-data that would cause a unique conflict) Or is it something lower down, say, at some interaction with DynamoDB (implied by the "catalog entry")?what’s the conventional “last step” after a query w/ entity pull to get the entities as a collection instead of a collection of single-entry collections? do we just use mapcat?
(i ask because this seems like the pull syntax does something important wrt laziness, and i would hate to overflow-bomb myself trying to map over a huge entity result)
@lwhorton re forward declaration: I learned a trick for this. all my entities have a shared uuid attribute. just before the save, I copy the str version of the uuid into the :db/id as a “temp-id”. this means that all references to that entity can now also use the string version in their ref attrs and Datomic will resolve them
hmmm. interesting. do you have the uuid (squuid?) generator as some out of band process elsewhere before you try to transact?
I don’t bother with squuids anymore (not required) so I just create the uuid in calling code for insert (it’s always read first for update)