Fork me on GitHub
#datomic
<
2019-03-06
>
johanatan00:03:42

Can someone explain how to use as-of and since bounds on the history function? per this doc (particularly the * delimited part):

history
function
Usage: (history db)
Returns a special database containing all assertions and
retractions across time. This special database can be used for
datoms and index-range calls and queries, but not for entity or
with calls. ***as-of and since bounds are also supported.*** Note that
queries will get all of the additions and retractions, which can be
distinguished by the fifth datom field :added (true for add/assert)
[e a v tx added]

johanatan01:03:06

I would expect a query containing the following three clauses to return exactly one (or none) results. Yet I'm seeing a bunch of them (with different values for ?max-time):

[?a :quote/time ?time]
    [(max ?time) ?max-time]
    [(= ?time ?max-time)]

favila01:03:54

max makes no sense here

johanatan01:03:04

yea, i was just thinking that

favila01:03:08

It’s the same as identity

johanatan01:03:18

what i'm trying to do is get the entity with the largest value for ?time

johanatan01:03:38

[these are time values within the data; not relying on datomic's own sense of time]

johanatan01:03:06

is there any way to do this without using a (d/history) database ?

johanatan01:03:25

what i need is to do a "function expression" binding at the :find level rather than within the :where clauses

johanatan01:03:32

but i bet that isn't possible/supported

johanatan01:03:09

as it would create a sort of circular dependency between the :find and the :where (not that that would be insurmountable)

johanatan01:03:10

oh, hmm. perhaps a nested query is the answer

favila01:03:13

Subquery is the easiest

johanatan01:03:19

yea, exactly 🙂

johanatan01:03:27

any reference demonstrating a sub query?