Zuriar
Zuriar

Reputation: 11764

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

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.

Upvotes: 4

Views: 1154

Answers (1)

Ben Kamphaus
Ben Kamphaus

Reputation: 1665

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).

Upvotes: 4

Related Questions