This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-03
Channels
- # beginners (98)
- # boot (18)
- # chestnut (2)
- # cider (90)
- # cljdoc (3)
- # cljs-dev (1)
- # clojure (64)
- # clojure-dev (14)
- # clojure-dusseldorf (4)
- # clojure-italy (11)
- # clojure-nl (5)
- # clojure-spec (9)
- # clojure-uk (69)
- # clojurescript (63)
- # code-reviews (2)
- # core-logic (20)
- # cursive (13)
- # datomic (52)
- # dirac (2)
- # emacs (4)
- # figwheel (6)
- # hyperfiddle (13)
- # luminus (4)
- # nrepl (1)
- # off-topic (7)
- # onyx (9)
- # overtone (3)
- # parinfer (3)
- # pedestal (1)
- # re-frame (31)
- # reagent (74)
- # reitit (34)
- # rum (3)
- # shadow-cljs (51)
- # spacemacs (22)
- # specter (7)
- # tools-deps (23)
- # uncomplicate (3)
- # vim (9)
Anyone else here have a problem when using cast/initialize-redirect :stdout
in cider?
is it possible to create an entity in datomic with no attributes, only refs to it?
Eg I have two entities, 123 and 456, and a :db.cardinality/one
:db.type/ref
attribute. If I transact [[:db/add 123 :my/ref "foo"] [:db/add 456 :my/ref "foo"]]
it fails
It'd be a ref to an empty entity. I'm guessing the answer is just "you can't have an empty entity with only incoming references".
Yeah, I mean thats your answer, because it would be kind of like a null entity.
I was more questioning what in your domain model would this empty ref represent and, if its a string like you proposed, should you think of "foo"
as a static value instead of an entity. I reserve entities for things that change over time but still need a stable id of some sort.
Entities are just a number. You can definitely have an "empty" entity with only 'incoming' refs
You could also do list form. Add to your example above:
[:db/add "foo" :db/id "foo"]
user=> (d/with db' [[:db/add 17592186046851 :my/ref "foo"] [:db/id 17592186046852 :my/ref "foo"] [:db/add "foo" :db/id "foo"]])
IllegalArgumentExceptionInfo :db.error/not-a-data-function Unable to resolve data function: :db/id datomic.error/arg (error.clj:57)
trying map syntax
oh! geez
user=> (d/with db' [[:db/add 17592186046851 :my/ref "foo"] [:db/add 17592186046852 :my/ref "foo"] [:db/add "foo" :db/id "foo"]])
IllegalArgumentExceptionInfo :db.error/not-an-entity Unable to resolve entity: :db/id datomic.error/arg (error.clj:57)
map version
user=> (d/with db' [{:db/id "foo"} {:db/id 17592186046851 :my/ref "foo"} {:db/id 17592186046852 :my/ref "foo"}])
IllegalArgumentExceptionInfo :db.error/tempid-not-an-entity tempid used only as value in transaction datomic.error/arg (error.clj:57)
fwiw this is not a huge issue, we can add a token attribute onto "foo". I just thought it was weird 🙂
You can also try reversing the attribute. i.e. redesign the attribute so that the currently empty entity contains forward-ref to other things
the only differences are ergonomic, *
in pull expressions and d/touch
won't look for them
om-prem, 0.9.5561
no this is correct, you can't use a tempid without using it as an :e in some assertion in the tx
Why does datomic.client.api/transact
not throw an error when called like this?
(d/transact conn [{:db/id bob-id
:user/name "bob"}])
This has bitten me so many times.