Fork me on GitHub
#datomic
<
2015-08-25
>
jonas16:08:56

Using the raw indexes I can do db.datoms(AVET, :some/attribute) to get all the datoms with a particular attribute, sorted by V. I'd like the iterator to be reversed (i.e., from the largest V to the smallest). Is this possible?

arohner16:08:03

@jonas: not built in, no. You can hack it by storing (- Long/MAX_VALUE your-value)

jonas17:08:18

@arohner: that seems nice and hacky, and kind of brilliant simple_smile. Would only work for numeric values I suppose

jonas18:08:56

How do people approach pagination in datomic? There’s no offset/limit in datalog and the datoms api doesn’t quite fit either.

jonas18:08:06

datomic seems nice in principle because you could get the next “page” from the same db value.

arohner18:08:00

@jonas: you can’t get pagination out of d/q, because it’s set-based. If you need iteration, you can look at d/datoms, d/seek-datoms and friends

arohner18:08:20

those can also be faster than d/q in some cases, but obviously only reach for that tool when necessary

jonas18:08:05

@arohner: yes, d/datoms would be perfect for my use case if I could get the reverse iterator.

jonas18:08:45

I want to paginate and sort by a date field so the log api might be a possibility as well.

tcrayford20:08:17

Note that the log isn't cached, so accessing it is relatively slow compared to the indices