datascript

2023-02-17T21:31:59.919909Z

Hi, I may be mistaken but is seems that the entity function returns an entity instead of nil when passed an numerical id that isn't in the db. From what I understand datascript.core/entity (which is an alias for datascript.impl.entity/entity) calls datascript.db/entid at the bottom which always returns the id passed to it if its a number. Is this a bug ? Am I missing something ? Cheers

Niki 2023-02-20T15:07:27.388479Z

If I remember it mimics Datomic behavior. Basically, do not use entities to check for existence. Entity call is supposed to be super-lightweight, so it doesn’t really touch DB unless you start asking for attributes

2023-02-21T12:10:55.959949Z

Ok thanks, I'll check with a normal query then. If I may though, for information, the docstring of d/entity has this example in it :

; If entity does not exist, nil is returned:
(entity db 100500) ; => nil
Thanks again, cheers