This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-23
Channels
- # announcements (2)
- # atom-editor (3)
- # babashka (49)
- # beginners (100)
- # biff (9)
- # calva (78)
- # clj-kondo (18)
- # clojure (143)
- # clojure-europe (13)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-spec (5)
- # clojure-sweden (2)
- # clojure-uk (4)
- # clojurescript (58)
- # conjure (1)
- # cursive (4)
- # datascript (11)
- # datomic (63)
- # docker (7)
- # emacs (18)
- # events (1)
- # fulcro (18)
- # graalvm (5)
- # helix (4)
- # improve-getting-started (13)
- # jobs (4)
- # jobs-discuss (3)
- # lsp (15)
- # malli (90)
- # membrane (14)
- # off-topic (12)
- # other-languages (5)
- # pedestal (7)
- # polylith (53)
- # re-frame (15)
- # reitit (23)
- # releases (4)
- # remote-jobs (9)
- # ring (11)
- # shadow-cljs (90)
- # specter (2)
- # testing (3)
- # tools-build (63)
- # vim (2)
- # xtdb (8)
How can I get datomic to tell me all the transactions that were transacted between start-time
and end-time
? I’ve gotten as far as
[:find ?e ?a ?v ?op
:in $ ?log ?start ?end
:where
[(tx-ids ?log ?start ?end) [?tx ...]]
[(tx-data ?log ?tx) [[?e ?a ?v _ ?op]]]]
, but that just gives me
#{[13194272974810 50 #inst "2022-02-22T14:38:18.227-00:00" true]}
How do I get to the actual value that was changed?This appears to be just one empty transaction. Try different start and end parameters to get others
What does 50
mean in that response?
Ah, hmm
Oh snap, that looks like exactly what I’m after, thanks a ton!
Yeah, I can see everything I’m looking for now, thanks again!
hi, technically i'm trying the following in datascript, but if there were some fundamental problem with my syntax, I'd hope this channel could spot it. why isn't the keyword mentioned in my predicate being filtered out?
core=> (cljs.pprint/pprint (d/q `[:find [?k ...] :where [?e :root/user ?r][?r ?k ?v][('not= ?k :user/feature-flags)]] @connection))
[:user/id
:user/disable-global-role?
:user/has-to-accept-license?
:user/first-name
:user/last-name
:user/feature-flags
:user/role
:user/company-id
:user/avatar-url
:user/app-roles
:user/email]
nil
if I try the complement, I get the same result list:
core=> (cljs.pprint/pprint (d/q `[:find [?k ...] :where [?e :root/user ?r][?r ?k ?v][('= ?k :user/feature-flags)]] @connection))
[:user/id
:user/disable-global-role?
:user/has-to-accept-license?
:user/first-name
:user/last-name
:user/feature-flags
:user/role
:user/company-id
:user/avatar-url
:user/app-roles
:user/email]
nil
is this a problem with datascript or my use of it?
(note that if I use =
or not=
rather than the quoted alternates, it complains that the built-in predicate doesn't exist. so i know it's at least doing some analysis of these predicates-- apparently just not actually running them).but we can see the list of ?k's returned in the result list here and they are keywords
e.g., the following has attribute keys in the "middle" position: https://github.com/tonsky/datascript/blob/cd129b7a9ef2fc31fa95873c376691f272752832/test/datascript/test/query_fns.cljc#L131
(d/q '[:find [?k ...] :where [?e :root/user ?r][?r ?k ?v][(not= ?k :user/feature-flags)]] @connection)
maybe that ?k
isn’t unifying with the one inside the (not= ?k ...)
for whatever reason
core=> (cljs.pprint/pprint (d/q '[:find [?k ...] :where [?e :root/user ?r][?r ?k ?v][(not= ?k :user/feature-flags)]] @connection))
[:user/id
:user/disable-global-role?
:user/has-to-accept-license?
:user/first-name
:user/last-name
:user/role
:user/company-id
:user/avatar-url
:user/app-roles
:user/email]
nil
core=> (cljs.pprint/pprint (d/q '[:find [?k ...] :where [?e :root/user ?r][?r ?k ?v][(= ?k :user/feature-flags)]] @connection))
[:user/feature-flags]
nil
interestingly i have the following elsewhere in my codebase for query generation and it works (notice the backtick):
(defn query-root-scalar [key]
`[:find ?v# . :where [~root-id ~(keyword "root" (name key)) ?v#]])
so it was invoking ('not= x :something)
which is symbol-lookup of not=
in collection x, or :something
as not found, so it was always returning :something
thus everything matched.
yea but here's the weird part: https://github.com/tonsky/datascript/blob/0.11.6/src/datascript/query.cljc#L140
I was getting "Unknown predicate error ..." when the predicate wasn't found in bulit-ins linked to above
mm, not sure. my brain is getting twisted at these meta levels. something weird was going on for sure.
> so will it hurt anything that all of my ?s will be “namespace-bound” It’s just weird, you may shake out edge cases
https://github.com/brandonbloom/backtick may make it easier to mix quasi-quoting and unqualified symbols
hi, is it possible to do a pull expression with a wildcard / except certain fields? something like the following:
[:find [(pull ?e [* !:this/field]) ...
such as the: into {}
portion of the following:
core=> (cljs.pprint/pprint (into {} (d/q '[:find ?k ?v :where [?e :root/user ?r][?r ?k ?v][(not= ?k :user/feature-flags)]] @connection)))
the library i'm using won't allow the "outside wrapper" transform such as above, so i'd need a way to get it inside the query itself
actually i don't think that would work. update
and dissoc
require a map which in my example doesn't exist until into {}
is executed
look at the reg-
functions below to understand why any "outer wrapper" solution won't work:
https://github.com/denistakeda/re-posh/blob/master/src/re_posh/subs.cljc
of course, it could be done with two subs, one taking the input from the first and then transforming it. but imagine that we want to do this for 100s of subscriptions and suddently 250 subs become 500 subs (which is overly verbose)
but i think i will just restructure the facts around this data, break it out to the top level