Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I insert a date in Datomic db.type/instant?

Tags:

datomic

Is there a neat way to save a Date into a Datomic attribute of type db.type/instant? For instance, there is a d/tempid and d/squuid functions to produce a tempid and a squuid.

like image 893
Zuriar Avatar asked Aug 31 '25 00:08

Zuriar


1 Answers

Datomic doesn't provide an API endpoint for generating dates as opposed to the cases for tempid (something Datomic makes a specific use of) and squuid (the generated value is changed from a standard uuid and will leak time information, which precludes some secure use, but allows for better indexing performance).

In Clojure code you can use the #inst reader literal or (java.util.Date.). You can obviously use the java.util.Date constructor in Java code as well (or use a library that generates the same type).

like image 84
Ben Kamphaus Avatar answered Sep 03 '25 18:09

Ben Kamphaus