Fork me on GitHub
#datascript
<
2015-08-25
>
conan11:08:28

I'm working on a legacy cljs application using datascript, and it uses strings for :db/ids. I want to upgrade datascript, but it seems I'm no longer allowed to use strings as eids - is there a good way of doing this? It would be infeasible to manually change all IDs in the code from strings to numbers.

Niki12:08:59

@conan: there’s no easy way

conan12:08:33

i was afraid you'd say that!

Niki12:08:39

You have to migrate to external ids, where string id is just an attribute with {:db/unique :db.unique/identity}

Niki12:08:01

you can keep referencing your entities using lookup syntax

Niki12:08:19

say you’d name your attr :external-id

Niki12:08:40

then you can use [:external-id <string>] almost everywhere entity id is expected

Niki12:08:04

and add to schema { :external-id {:db/unique :db.unique/identity} }

conan12:08:17

yeah, i see. :db/id really is just an internal database id, not meant for cramming stuff into (as we did, we put uuids in there)

conan12:08:53

thanks though, it saves me a lot of time to know that!

Niki12:08:42

yep, it was fun to being able to store anything in ids

Niki12:08:50

but performance really suffer

Niki12:08:40

now, if you really need it, you walk an extra mile, but by default you don’t pay that price

damien14:08:10

@tonsky: question about rum: would there be any issues using something like re-com UI components with the reactive mixin?