datascript

2021-09-14T13:16:18.022800Z

Hi, I have a question about syncing Datomic (Cloud) data to Datascript. I found an article saying: “Datomic entity IDs can be larger than JavaScript’s`Number.MAX_SAFE_INTEGER`” which means he needed to use a workaround (string). Is this still a problem, are there other solutions?

2021-09-14T13:16:36.022900Z

The article is https://jacobobryant.com/post/2019/ion/

2021-09-14T15:11:47.023100Z

this is definitely still a problem; JS doesn't guarantee integers larger than 29 bits or something, and Datomic uses 64-bit IDs for everything.

2021-09-14T15:12:56.023300Z

so generally I'd say that whatever API you're using to sync Datomic data to DataScript should convert IDs to strings. it's less obvious what to do with actual data values.

2021-09-14T15:13:55.023500Z

I mean, a :db.type/long field has the same problem. your data may not be too big though.

2021-09-14T15:16:33.023700Z

Thank you Braden, I’ll use the string strategy then.

Josh 2021-09-14T20:13:10.023900Z

I’ve done something similar before, we added a unique attribute :ent/uid (uuid’s or some other uniquely generated string) to every entity and dropped the db/ids when syncing