Fork me on GitHub
#datomic
<
2016-12-24
>
dottedmag22:12:46

I'm reading "Identity and Uniqueness" page of Datomic docs, and it says the following about idents: "When you navigate the entity API to a reference that has an ident, the lookup will return the ident, not another entity." -- what does it mean? I can't wrap my head around "navigate the entity API to a reference".

pesterhazy22:12:58

A reference, or ref, is a value type

pesterhazy22:12:39

A car has a model

pesterhazy22:12:13

:car/model, the attribute, is a ref

pesterhazy22:12:56

If you navigate from the car to the model entity and the model happens to have an ident, the entity map will return the ident

dottedmag23:12:08

Ah, I see. It is to implement enums.

dottedmag23:12:15

@pesterhazy Thanks

dottedmag23:12:44

Interesting. I have created an entity with a reference to non-existing entity, and it worked: (datomic.api/transact conn [[:db/add "jdoe" :db/lang 44444444]]) -- is that expected?

dottedmag23:12:27

Both this entity and entity with id 44444444 were created as a result.

dottedmag23:12:33

It's interesting that there is no type for a "closed" enum, unless one counts :db.type/boolean as one.