This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-07-16
Channels
- # aws (17)
- # babashka (2)
- # beginners (131)
- # bristol-clojurians (1)
- # calva (16)
- # chlorine-clover (6)
- # cider (10)
- # clara (5)
- # cljsrn (82)
- # clojure (176)
- # clojure-dev (14)
- # clojure-europe (13)
- # clojure-italy (13)
- # clojure-nl (4)
- # clojure-spec (10)
- # clojure-sweden (32)
- # clojure-uk (32)
- # clojuredesign-podcast (2)
- # clojurescript (34)
- # community-development (2)
- # conjure (17)
- # cursive (4)
- # datomic (51)
- # emacs (6)
- # figwheel-main (26)
- # fulcro (16)
- # graalvm (11)
- # jobs (2)
- # jobs-discuss (30)
- # kaocha (4)
- # meander (23)
- # off-topic (34)
- # pathom (5)
- # re-frame (10)
- # reagent (3)
- # reitit (6)
- # releases (3)
- # sci (36)
- # shadow-cljs (27)
- # sql (9)
- # testing (6)
- # tools-deps (28)
- # vim (8)
Relative newcomer to Datomic and I’ve been banging my head against a wall… wonder if anyone has any hints. If the entity “person” has a cardinality-many attribute “friends,” I want to fetch a person where all of that person’s friends have a certain predicate. Plain and simple unification seems to return a person when any of its friends have the predicate. So I need to reach for something else, but I don’t know what that is.
You can use not/not-join to check that a person doesn't have any friends that don't satisfy the predicate.
Let me take it one step further. If my “friends” entities all have a cardinality-many attribute “pets,” how could I grab a person who only has friends that have at least one dog? I don’t necessarily want to exclude people who have friends who have cats, so long as each friend also has at least one dog.
I believe this should work also (haven't tested it fyi):
; "Doesn't have a friend who doesn't have a dog"
(not-join [?person]
[?person :person/friends ?friend]
(not-join [?friend]
[?friend :person/pets ?pet]
[?pet :pet/type :dog]))
Doesn't seem too hairy IMO
Well I figured out the "no protocol" error message. It just wanted me to add "https::/" to the url. I hadn't thought about protocols with the web since I last used ftp.
Anyways I figured out which aws api I should be using, so I switched to aws-api
from clj-http
. So my questions now are not really datomic related (not really a problem using ions anymore, but aws-api). I'll head over to #aws I guess, but on my way out does anyone know why the following does not actually send a response to wscat
? I have tries all kinds of things for :Data which is supposed to be a blob
including (a json string, a json smile, a .getBytes of json string, a plain test string, and the object shown below)
(aws/invoke (aws/client {:api :apigatewaymanagementapi})
{:op :PostToConnection
:request {:Data {"action" "pong"}, :ConnectionId id}})
Let me take it one step further. If my “friends” entities all have a cardinality-many attribute “pets,” how could I grab a person who only has friends that have at least one dog? I don’t necessarily want to exclude people who have friends who have cats, so long as each friend also has at least one dog.
does datomic allow for doing queries with limit and offset and maybe sorting? ( trying to do pagination )
No: datomic query results are sets or bags and so inherently unordered, so limit and offset doesn’t make sense. You are expected to either find a natural paging boundary and use that as input to the query to limit results (e.g. results a day at a time), or sort and page yourself afterwards.
That said, the client api has limit and offset parameters, but I wouldn’t rely on them for user-facing paging for the reasons stated
got it, oh well .. i guess i just suck it up ( thanks @U09R86PA4
Is there any guarantee that the order of a carnality many attribute remain the same given no new transactions? e.g., something like this would be true.
(->> (range 1000)
(map (fn [_] (d/pull db [::card-many] eid)))
(partition-all 2 1)
(every? #(= %1 %2)))
Hmm, okay. It makes testing certain things a bit more of a pain. Since pull
returns vecs I have to convert everything to sets to test equality.
https://docs.datomic.com/cloud/query/query-pull.html#xform-option is the scripture here
Am I missing something here?
(slurp (io/resource "datomic/ion-config.edn"))
=> "{:xform [clojure.core/set]}"
(d/pull db '[{[::card-many :xform clojure.core/set] [*]}] eid)
Execution error (ExceptionInfo) at datomic.ion.resolver/anomaly! (resolver.clj:41).
'clojure.core/set' is not allowed by datomic/ion-config.edn
Not sure what you mean. I thought it supports all Datomic features, one of which is :xform
. You config :xform
via datomic/ion-config.edn
, no?
btw the original question was "does pulling cardinality many attrs guarantee a particular order?"
@U083D6HK9 sure if you could drop that example in a ticket we can track it there
Wait, my question was more specific @U050ECB92. Is there any guarantee that the order of a carnality many attribute remain the same given no new transactions?