datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
2021-05-17T08:17:56.153700Z

Hello ! I have a 3 questions about sorting. There is a fairly large collection of photos, each photo has a ‘photo/taken-at’ attribute with value type instant. I want to retrieve 100 photos ordered by taken-at potentially in reverse chronology. What is the idiomatic way to achieve that ? So far I’ve managed to do it using ‘index-pull’ which also has offset, limit and reverse options. Is this the way to do it ? Then, if I want to find a specific photo title in the oldest 100 photos, I would first retrieve the ids using index-pull, then perform a parameterized :find using those ids and the substring as parameters to the query. Alternatively, if I want to find the title in all photos, I first perform the query, then do a sort-by :taken-at on the results. So 3 questions really, but all related :). Is my thinking correct? Thank you !

florinbraghis 2021-05-19T13:29:07.001900Z

Thank you !

pyry 2021-05-17T12:16:48.154300Z

1. Can't claim to vouch for a huge user base, but I'd say that is indeed idiomatic. A good choice, at any rate.

pyry 2021-05-17T12:22:56.154500Z

2. That should work. I guess you could also just add the photo title to the :selector and filter "by hand".

pyry 2021-05-17T12:24:22.154700Z

3. Again, I think you could just add the photo title to the :selector instead?