Entity existence check documentation clarification

Entities | Datomic states that " Entities are not suitable for existence tests, which should typically be performed via lookup of a unique identity."

However, for years I used (empty? (d/entity …)) as a very successful “existence test”. Is that not reliable or unstable?

2 Likes

I’ve only done some very light testing, but it seems that the more attributes an entity has, the more expensive it is to call empty? on it.

Still, I’m very interested in the answer to your question, because I tend to existential checks using a lookup ref (d/entity db [:a-unique-attribute ...]), which as far as I can tell will return nil if the entity does not exist.

Have you found a better way to do this?