This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-03
Channels
- # aleph (1)
- # announcements (3)
- # aws (36)
- # babashka (35)
- # beginners (25)
- # cider (14)
- # clj-kondo (3)
- # clojure (154)
- # clojure-europe (8)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-serbia (1)
- # clojure-uk (133)
- # clojurescript (36)
- # cursive (15)
- # data-science (7)
- # datomic (16)
- # fulcro (34)
- # immutant (9)
- # jackdaw (5)
- # jobs (1)
- # leiningen (39)
- # off-topic (25)
- # pathom (42)
- # planck (13)
- # play-clj (1)
- # re-frame (18)
- # reagent (6)
- # reitit (3)
- # remote-jobs (1)
- # ring-swagger (16)
- # shadow-cljs (67)
- # sql (22)
- # testing (1)
- # uncomplicate (2)
- # vim (21)
- # vscode (6)
Hello, I'm trying to figure out how to model relationships in a a graph database, and I've got a puzzle. I want to be able to link one entity to another multiple times:
(d/transact db/conn [{:db/ident :container/name
:db/valueType :db.type/string
:db/unique :db.unique/identity
:db/cardinality :db.cardinality/one}
{:db/ident :container/stuff
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
{:db/ident :thing/name
:db/valueType :db.type/string
:db/unique :db.unique/value
:db/cardinality :db.cardinality/one}])
(d/transact db/conn [{:container/name "a"}
{:container/name "b"}])
(d/transact db/conn [{:thing/name "thing1"}
{:thing/name "thing2"}
{:thing/name "thing3"}])
(d/transact db/conn [{:container/name "a"
:container/stuff [[:thing/name "thing3"]]}
{:container/name "b"
:container/stuff [[:thing/name "thing1"]
[:thing/name "thing1"] ; note that I'm repeating "thing1" twice
[:thing/name "thing2"]]}])
(d/q '[:find (count ?thing) .
:where
[?e :container/name "b"]
[?e :container/stuff ?thing]]
@db/conn)
;;=> 2 I would expect this to return 3
Datomic facts are sets, so there are no duplicate facts. You can’t assert “b contains thing1” multiple times
Having a count entity is unlikely to help because you’re going to run in to the same problem when you try to decrement
I want to learn fact-modeling and so I'm building an api for a pen and paper RPG rulebook. I'm trying to model advances. Each class has a set of advances, some of which they can take multiple times. A lot of those advances are shared between classes as well.
In sql terms, this would just be a join table with (advance_id, class_id, count), I think. But I'm not sure how to express that here.
Could you use something like this?
:db/valueType :db.type/tuple
:db/tupleTypes [:db.type/ref :db.type/long]
:db/cardinality :db.cardinality/many
:db/doc "Tuples of [Advance-Ref, Count]"
I'm currently playing around with datahike which doesn't support tuple types, so I can't try that out right now.
Currently, I've just removed the :db/unique
property and I'm just dealing with the duplicates
Should lookup refs work with tuple attributes? Example code here that does not work as expected: https://gist.github.com/ivarref/0bb0e1f51919760be7c953ccd0b12279 Or am I missing something? Thanks.
Apparently pull does not work with ref. According to this gist https://gist.github.com/robert-stuttaford/e329470c1a77712d7c4ab3580fe9aaa3#using-refs-in-tuples.
Although I don't know where is that list of valid :db.type/ref
for tuples.
Running datomic on-prem 0.9.5951
in AWS EB, the connection is created on server init.
I'm seeing the following exception some time after a web service starts.
A google search only returns one hit (a slack thread from Feb 2014!)
Has anyone else encountered this, or may be able to hint at what might be the issue?
08:59:48.688 WARN datomic.common [clojure-agent-send-off-pool-3]
... caused by ...
java.lang.IllegalStateException: Connection pool shut down