Fork me on GitHub
#datomic
<
2017-11-14
>
souenzzo00:11:11

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)?

souenzzo12:11:05

Can I bump this? 😅 P.S.: I'm looking for cursors.

mitchelkuijpers12:11:12

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.

zignd00:11:31

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

souenzzo01:11:24

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.

zignd02:11:32

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

favila05:11:58

The db/id here is ?u! Just replace that with ?p-user-id

zignd09:11:16

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

zignd09:11:58

things now make much more sense

csm00:11:20

just use ?p-user-id in place of ?u

csm00:11:32

and omit the :db/id lookup

zignd00:11:38

Oh, that makes sense! Thanks @csm

zignd03:11:15

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)

souenzzo11:11:32

It's a (or-join [?tweet-id] ...), not?

zignd16:11:25

@U2J4FRT2T do you mean this?

(or-join [?tweet-id :tweet/author-id ?followed-id]
           [?tweet-id :tweet/author-id ?user-id])

zignd16:11:13

I'm not at my computer right now, but I'll will try it out as soon as I get to it

souenzzo16:11:59

(or-join [?tweet-id]
          [?tweet-id :tweet/author-id ?followed-id]
          [?tweet-id :tweet/author-id ?user-id])

zignd03:11:26

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

augustl12:11:28

I suspect that it's possible that the order is not stable, based on nothing but guessing

augustl12:11:51

maybe the ording changes randomly after re-indexeing. Then again, all the data is stored in sorted sets, so maybe it's consistent

uwo16:11:31

If we’re getting ‘transactor unavailable’, are there other culprits besides write-heaviness? This isn’t during imports.

Ben Kamphaus17:11:07

@uwo could also be memory pressure on the peer, GC, etc. — it’s a peer<->transactor timeout so can be on either side.

uwo17:11:39

hmm. thanks

currentoor21:11:47

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?

jaret16:11:56

We’re targeting Q4 for release of Cloud

currentoor18:11:38

Hi @U1QJACBUM, thanks for the reply.

currentoor18:11:59

Just to confirm that’s Q4 this year right?

jaret19:11:26

Yep, this year.