datomic

raspasov 2025-05-22T05:07:12.604579Z

I tried looking around, and I couldn’t find anything but just in case: Is there a way to “create” a Datomic datom object out of existing data (without writing it to Datomic first)?

raspasov 2025-05-22T05:08:19.211289Z

Similar to Datascript’s datom fn:

(datascript.core/datom 1 :attr "value") 
=> #datascript/Datom [1 :attr "value" 536870912 true]

raspasov 2025-05-22T05:10:03.595799Z

I realize I could make a new/custom deftype that mimics all of the datomic.db.Datum interfaces but I would prefer to avoid that if possible.

tatut 2025-05-22T08:13:25.048949Z

use with?

(d/with (d/db conn) [[:db/add 666 :some/attr "bar"]])
and the return value :tx-data will have them

💡 1
raspasov 2025-05-22T08:41:44.215899Z

Thanks! That might do!

tatut 2025-05-22T08:59:00.493659Z

out of curiosity, why do you need a datum instance?

➕ 1
raspasov 2025-05-22T17:52:51.623689Z

I am writing an IVM query engine for Datomic/Datascript

👍 1
raspasov 2025-05-22T17:55:16.114419Z

It might not be strictly necessary, but it’s sometimes more convenient to instantiate Datoms to write a basic unit test to compare to output result set, for example

Joe Lane 2025-05-23T02:38:13.058339Z

Modeling it after DBSP?

🎯 1
raspasov 2025-05-23T04:17:58.778169Z

Yes

tatut 2025-05-23T04:24:42.756609Z

interesting