Fork me on GitHub
#datomic
<
2017-11-23
>
boldaslove15611:11:32

Do you guys think it's okay to expose eid to client as part of a url?

val_waeselynck11:11:44

No, consider them internal

kirill.salykin11:11:09

so, it is better to have some uuid or int id which can be exposed?

pesterhazy15:11:45

yes. lookup refs can be used everywhere an eid can, e.g. [:person/id #uuid "asdf-asdf-asdf-asdf"]

zignd00:11:44

may I ask why it's not okay? i'm building an http service and returning them to the service's client, just curious idk, i might be doing something wrong xD

favila00:11:43

They are not guaranteed to be unchanging. So there should be no long-lived weakly-referenced entity ids in your system (eg in a url, or in a json blob stored somewhere). In your example, your urls night break one day.

favila00:11:18

Using eids in short-lived contexts is ok

zignd01:11:33

thanks for the explanation! i'll look into this lookup refs

pesterhazy08:11:08

eid haven't changed in practice so this may not be important practically speaking

pesterhazy08:11:08

but remember that if you re-create a database in some way other than restoring (i.e. re-inserting datoms), you won't have control over eids

zignd11:11:53

yeah, that's what i noticed reading the docs on Identity and Uniqueness, thanks for confirming

zignd11:11:08

it works just like an identity column in a relational database configured auto increment

augustl11:11:44

@U06F82LES what will happen if you use [:person/id #uuid "....."] and the string is not a valid UUID?

augustl11:11:10

my argument for using strings for UUID types has been that I don't want to manually convert to an UUID object and have to catch the exception that java throws if it's invalid and return a 404 instead of a 500 in my web servers

augustl11:11:23

but maybe the #uuid tag behaves differently

pesterhazy11:11:30

@U0MKRS1FX you'll get a reader exception

pesterhazy11:11:48

but yeah you'd have to catch the exception manually I think if you care

augustl12:11:35

ah, I'll stick to strings, then. I'm lazy 🙂

augustl12:11:37

thanks for the info!

zignd00:11:44

may I ask why it's not okay? i'm building an http service and returning them to the service's client, just curious idk, i might be doing something wrong xD