This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-23
Channels
- # babashka (68)
- # beginners (133)
- # calva (5)
- # chlorine-clover (21)
- # cider (40)
- # clj-kondo (42)
- # cljs-dev (31)
- # clojure (53)
- # clojure-austin (1)
- # clojure-europe (30)
- # clojure-italy (6)
- # clojure-nl (3)
- # clojure-uk (104)
- # clojurescript (15)
- # datascript (2)
- # datomic (50)
- # emacs (12)
- # fulcro (82)
- # graalvm (4)
- # hoplon (225)
- # jobs (4)
- # jobs-discuss (7)
- # joker (5)
- # juxt (17)
- # kaocha (13)
- # leiningen (16)
- # meander (21)
- # nrepl (18)
- # off-topic (16)
- # pathom (8)
- # pedestal (13)
- # perun (1)
- # re-frame (4)
- # spacemacs (23)
- # testing (28)
- # unrepl (3)
- # vim (5)
- # xtdb (1)
Hi, I’ve encountered some issue while I was playing around with datomic, I’ve described my problem on stackoverflow https://stackoverflow.com/questions/60807032/fixing-a-datomic-anomalie
e.g.
[{:db/ident :trip/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one}]
a general datomic question: does (datoms ...)
return only the existing, unretracted values? or does it return the full history?
databases all have a basis-t, and can also have any/none of: • as-of • since • history • filter
filter is an arbitrary predicate that runs after all of the above and can suppress datoms from showing up.
If you want full history then you have to pass historical database i.e
(def hist-db (d/history (d/db conn))
;;
(d/datoms hist-db ...)
If you pass the the current value of database, then it will returns all the datoms that are valid at the current time.
1. composite unique tuple on two other attrs. one attr is the partnership, the other is a unique identifier for that partnership. [partner partner-id]
2. haven't re-transacted those attrs to cause tuple attrs to appear yet
3. want to retract a bunch of redundant values on one of the target values, to avoid having to re-assert for the tuple.
4. transaction at 3 fails because now it's trying to set the same value [partner nil]
for the tuple, which fails the uniqueness check.
Can I retract tuple attrs directly? I know I can't retract them now because they don't exist yet, so it seems that I have to first re-assert these values so that tuple datoms are made, and then retract both the identifier and the tuple datoms to clear away the old values.
Happy to rewrite any of this if it doesn't make sense 🙂
My other option is to do a cleanup before asserting the tuple schema, which is still something I can do -- just looking to learn how to deal with this when that is no longer an option 🙂
@robert-stuttaford I think the cleanup beforehand is your best option right now
We are aware of the complications with automatic composite tuples; don’t have a specific workaround once the unique composite is declared
for interest's sake, let's say that door was closed. am i hosed, or is there a way, even if longwinded?
ok. is there a way to directly assert updates to tuple attrs? or is it only ever via altering their targets?
thanks for answering so quickly! it was rad to hang out in Berlin, which feels like it was months and months ago now, haha
that makes sense, thanks!
What I want from this query is "Give me the :db/id
of the datom that has the largest :foo/end-time
"? Is this the correct way to do it? I call ffirst
on the output and get what I'm looking for, I'm just not sure of max
's behavior with :db/id
.
(d/q {:query '[:find (max ?target) (max ?end-time)
:where [?target :foo/bar? false]
[?target :foo/end-time ?end-time]]
:args [db]})
You can’t use aggregation for this. You want to fetch the full result, find the highest end-time, and select the target
So if I wanted to bound the total amount of records that this query could return, I'd need to do that some other way?
if the db
you're passing is not a history db but a regular db, ordinary queries return the latest assertion for something
so only history dbs contain all of the past datoms, regular db is "now" (at a particular 't')
I have n (and growing) foo
s in this example. Right now the query would return all of the records where ?target :foo/bar? false]
which is "most" of them
[?target :foo/end-time ?end-time]
[(> ?end-time threshold)]
and pass in e.g. yesterday as the threshold?https://stackoverflow.com/questions/23215114/datomic-aggregates-usage/30771949#30771949