This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-14
Channels
- # beginners (33)
- # boot (38)
- # clara (21)
- # cljs-dev (1)
- # cljsjs (2)
- # cljsrn (12)
- # clojure (230)
- # clojure-argentina (1)
- # clojure-brasil (3)
- # clojure-dusseldorf (4)
- # clojure-france (9)
- # clojure-italy (1)
- # clojure-russia (123)
- # clojure-spec (46)
- # clojure-turkiye (1)
- # clojure-uk (60)
- # clojurescript (83)
- # core-async (6)
- # cursive (10)
- # datascript (19)
- # datomic (28)
- # defnpodcast (1)
- # emacs (7)
- # figwheel (7)
- # fulcro (29)
- # leiningen (29)
- # lumo (9)
- # off-topic (14)
- # om (1)
- # onyx (25)
- # pedestal (1)
- # protorepl (3)
- # re-frame (10)
- # reagent (41)
- # ring-swagger (11)
- # shadow-cljs (10)
- # testing (5)
- # unrepl (3)
- # vim (3)
Let's suppose (d/q '[:find [?e ...] :where [?e :foo/bar]] (d/as-of db 555))
will return [1 2 3]
.
This order is stable (always using db at basis 555)?
Datomic will never guarantee the order of results so you should never depend on this. In practice it seems to be mostly ordered but I would not depend on this behaviour because it is a implentation detail which they won't guarantee.
Is it possible to use an entity's id in a query? I tried to create a pattern using :db/id
but apparently that's not the way to do so.
(d/q '[:find ?t ?content ?display-name
:in $ ?p-user-id
:where
[?u :db/id ?p-user-id]
[?t :tweet/author-id ?u]
[?t :tweet/content ?content]
[?u :user/display-name ?display-name]]
(d/db conn) zignd-id)
> CompilerException java.lang.Exception: processing rule: (q__11193 ?t ?content ?display-name), message: processing clause: [?u :db/id ?p-user-id], message: :db.error/not-an-entity Unable to resolve entity: :db/id
See also:
(d/touch (d/entity (d/db conn) :db/ident))
(d/touch (d/entity (d/db conn) :db/id))
:db/ident
, as :tweet/author-id
are attributes
on datomic. They have a description.
:db/id
isn't. So you cant use it on second position of the query tuple.
(d/touch (d/entity (d/db conn) 0))
also a cool place to explore.Interesting the results of calling this touch
function, knowing that makes the fact that I was creating a pattern for :db/id
even more pointless xD
thanks guys i understand it now, it just took me sometime to realize that the e in the [e a v t] format could be parameterized and that it was a value, just like to ones you use in the v part of the format
How do I properly use the or
clause? I trying to follow the docs here http://docs.datomic.com/query.html#or-clauses, but I'm starting to think my use case may require something else, maybe some sort of join. My guess is that it's somehow related to the fact I'm trying to create a pattern involving a value coming from an input and another from within the query itself.
(d/q '[:find ?tweet-id ?content ?display-name
:in $ ?user-id
:where
[?follow-id :follow/follower-id ?user-id]
[?follow-id :follow/followed-id ?followed-id]
(or [?tweet-id :tweet/author-id ?followed-id] ; I'd like to have an `or` clause here. Because I also need to retrieve the :tweet entities in which the author is the ?user-id itself
[?tweet-id :tweet/author-id ?user-id])
[?tweet-id :tweet/content ?content]
[?followed-id :user/display-name ?display-name]]
(d/db conn) zignd-id)
> Assert failed: All clauses in 'or' must use same set of vars, had [#{?followed-id ?tweet-id} #{?user-id ?tweet-id}] (apply = uvs)
@U2J4FRT2T do you mean this?
(or-join [?tweet-id :tweet/author-id ?followed-id]
[?tweet-id :tweet/author-id ?user-id])
(or-join [?tweet-id]
[?tweet-id :tweet/author-id ?followed-id]
[?tweet-id :tweet/author-id ?user-id])
The query properly retrieves the :tweet
entities in which ?user-id
is not an author when I'm using the [?tweet-id :tweet/author-id ?followed-id]
pattern instead of the (or [?tweet-id :tweet/author-id ?followed-id] [?tweet-id :tweet/author-id ?user-id])
though
I suspect that it's possible that the order is not stable, based on nothing but guessing
maybe the ording changes randomly after re-indexeing. Then again, all the data is stored in sorted sets, so maybe it's consistent
If we’re getting ‘transactor unavailable’, are there other culprits besides write-heaviness? This isn’t during imports.
@uwo could also be memory pressure on the peer, GC, etc. — it’s a peer<->transactor timeout so can be on either side.
I enjoyed the intro to Datomic Cloud Native by @stuarthalloway at the Conj. Any updates on when that will be released? Is it still expected to be ready by end of this year?
Hi @U1QJACBUM, thanks for the reply.
Just to confirm that’s Q4 this year right?