Fork me on GitHub
#crux
<
2020-09-06
>
lispyclouds10:09:51

Hello! What would be the way to order the results of a find query according the the valid time or even the transaction time? From the docs I understand the :order-by key takes a field from the submitted document?

refset10:09:45

Hey! Assuming you are pulling entity IDs out of the find then you would need to map over the tuples to lookup the relevant tt/vt time for each using entity-history and then sort on those values as a final step. We are looking at exposing the various times directly into query execution (as this kind of thing isn't an uncommon request!) but unfortunately it's not something we will be delivering in the short-term. I would be really interested to hear more about the use-case though as it may help guide us towards the eventual solution. For instance, are you thinking about displaying sorted data grids to users that include audit times?

lispyclouds11:09:23

Hey @U899JBRPF thanks for the info. Yes I'm looking for a pull of various docs which have a particular value for a key and these need to be ordered in the ttime. they got transacted. The use case is that I'm using Crux for a CI/CD system I've been building and this is for the clients to pull the logs of a build given a run-id. Each log is a doc with a unique id and it contains the log line. Since log lines need a temporal ordering, I wanted to exploit the time aspects of crux and was hoping that I dont need a time field in the log document and can order it during the pull. Hope I'm thinking right? Any more pointers are most welcome and happy to share more details 😄

refset11:09:11

Cool, that helps, thanks. I think the approach suggested is probably the right thing to do. You will get better performance by using open-db to share resources across the various parts of your overall query.

1
refset11:09:03

Storing the transaction time as a field on the doc itself isn't really possible without using transaction functions, but if you go down that route you may even prefer to put a reified transaction document alongside your docs, containing additional metadata (including transaction time)