Fork me on GitHub

Q: I want to query “last-updated” date-time for n entities. it’s not obvious how to do this because a change to any attribute in the entity is an “update”. has anyone found a way to do this?


Explicitly model it. Don't use Datomic’s history for this.


I have done that for parent entities when children are updated. why model this instant value when it is in history?


Because you have control over it.


fair enough. having thought about it a bit, I’m going to follow your advice. thx for the nudge

Ivar Refsdal11:03:46

PS. Don't forget that two (Date.) may be equal, i.e. refer to the same millisecond. Thus if you are asserting: :e/updated (Date.) twice fast enough on the same entity, you may loose data. If you are not loosing data now, you may in the future as latency decreases. I'm not sure it's a very good idea to explicitly model this. To me it seems this should be something that Datomic "can do". I have solved this (for certain types of data) in You can have a look at the function pull-flat-history. This allows you to get the (relative) latest update of some entity.

Ivar Refsdal11:03:35

Warning. I'm pretty sure pull-flat-history is slow.