This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-11-30
Channels
- # adventofcode (4)
- # aleph (1)
- # announcements (7)
- # aws (10)
- # babashka (23)
- # beginners (23)
- # calva (20)
- # chlorine-clover (13)
- # cider (17)
- # clj-kondo (13)
- # cljfx (9)
- # cljsrn (9)
- # clojure (98)
- # clojure-australia (1)
- # clojure-dev (15)
- # clojure-europe (127)
- # clojure-nl (4)
- # clojure-sanfrancisco (3)
- # clojure-uk (98)
- # clojurescript (25)
- # community-development (8)
- # core-async (15)
- # cryogen (9)
- # cursive (7)
- # data-science (1)
- # datascript (5)
- # datomic (3)
- # devcards (2)
- # fulcro (5)
- # graalvm (1)
- # helix (8)
- # jackdaw (1)
- # jobs (5)
- # kaocha (17)
- # malli (5)
- # meander (5)
- # off-topic (37)
- # pathom (33)
- # pedestal (3)
- # re-frame (12)
- # reitit (1)
- # remote-jobs (3)
- # sci (1)
- # shadow-cljs (6)
- # testing (1)
- # vim (6)
- # vrac (5)
Hello, I'm trying to take a subset of information from Datomic and use it with Datascript. The entities have this shape:
{:db/id 17592186048456
:user/email ""
:user/birthdate #inst "1997-07-07T10:00:00.000-00:00"
:user/lastname "BAR"
:user/firstname "Foo"}
When I transact this data I have the following error Highest supported entity id is 2147483647, got 17592186048456
.
I played with Datascript and Datomic:
(->> datomic-db
(d/q '[:find ?user .
:where [?user :user/email]])
type)
;; => java.lang.Long
(as-> (ds/create-conn) <>
(ds/transact! <>
[{:db/id "temp-id"
:user/email ""
:user/birthdate #inst "1997-07-07T10:00:00.000-00:00"
:user/lastname "BAR"
:user/firstname "Foo"}])
(:db-after <>)
(ds/q '[:find ?e .
:where
[?e :user/email]]
<>)
(type <>))
;; => java.lang.Integer
Is there a particular reason for having different types for db ids?
Is there a way to tell Datascript to use Long
instead of Integer
?
ping @tonsky
Thanks
@dam this is a limitation that DataScript imposes, because (a) JS is limited to 32-bit signed integers, and (b) even that is further split into two buckets: one range for datom-ids and second range for transaction-ids. See https://github.com/tonsky/datascript/blob/master/src/datascript/db.cljc#L19-L22
As a rule of thumb, it's not recommended to expose the :db/id
directly to an external API, but use a different stable unique identifier (or an UUID if nothing more relevant is available). This is a good idea even when working with Datomic directly (e.g. if you decide to re-transact your data into a new Datomic instance, you're not guaranteed to have the same eids).