datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
Pragyan Tripathi 2021-05-15T06:11:48.109700Z

Hello Guys. Is there a correct way to store raw edn data in datomic? Only way I could figure out is stringify the edn and parse it when reading.

benoit 2021-05-15T13:03:27.109800Z

You can't store Clojure values as-is in Datomic. You have to represent them using the Datomic schema. https://docs.datomic.com/cloud/schema/schema-reference.html#db-valuetype You can always store an EDN string using the :db.type/string type but it is limited to 4096 characters according to the docs (same link). Also, keep in mind that you won't be able to query against the values inside your EDN string.

souenzzo 2021-05-15T20:46:22.110Z

on datomic on-prem, you can use bytes + nippy

Pragyan Tripathi 2021-05-16T11:23:22.115900Z

I figured out a way to use refs in my schema to solve my problem... Thanks 🙂

benoit 2021-05-15T13:03:27.109800Z

You can't store Clojure values as-is in Datomic. You have to represent them using the Datomic schema. https://docs.datomic.com/cloud/schema/schema-reference.html#db-valuetype You can always store an EDN string using the :db.type/string type but it is limited to 4096 characters according to the docs (same link). Also, keep in mind that you won't be able to query against the values inside your EDN string.

souenzzo 2021-05-15T20:46:22.110Z

on datomic on-prem, you can use bytes + nippy

Yarin Kessler 2021-05-15T21:54:25.112100Z

The following query was taken straight from Datomic docs (https://docs.datomic.com/cloud/query/query-data-reference.html#variables), but when I run it it goes into an infinite loop of continuous data output, forcing my to terminate my REPL. Any idea why?

(d/q  '[:find ?name ?duration
        :where [?e :artist/name "The Beatles"]
        [?track :track/artists ?e]
        [?track :track/name ?name]
        [?Track :track/duration ?duration]]
      db)
(Running this against mbrainz (https://docs.datomic.com/cloud/examples.html#datomic-samples) on local-dev instance)

alexmiller 2021-05-15T22:10:13.113500Z

Is that capital ?Track in there? Seems like that should be lowercase to match the others

1🙌
alexmiller 2021-05-15T22:11:17.114200Z

Might be creating an unintended free variable

alexmiller 2021-05-15T22:12:58.114500Z

@ykessler ^^

Yarin Kessler 2021-05-15T22:17:13.114600Z

YES! Thanks Alex- I never would have spotted that!

alexmiller 2021-05-15T22:45:14.115700Z

I dropped a note in our internal support channel to fix the docs, sorry about that