You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:db/id is not a real attribute. It is used to create “map” forms of an entity at insert stage. When you write
(d/transact! db [{:db/id -1 :name "Mazinger"}]
it means, essentially, this: take all key-value pairs from this map, convert them to [:db/add eid attr value] form where attr=key from map, value=value from map, and eid (entity id) is a special key :db/id from map. It’s just a convention. Results from entity calls support this convention too, as they have to represent datoms as maps.
But inside DataScript everything is stored as flat datoms of form [e a v], no maps. If your entity has 10 attributes, there’ll be 10 distinct datoms. Maps are just a convenient view of these internals.
Queries are written in pattern-match style over actual flat datoms, so you cannot use :db/id as it is not an actual datom attribute. When matching over entity id, just use first position, not last one:
Example:
Entity is not returned when querying using
:db/id
. Is this a limitation by design or a bug?The text was updated successfully, but these errors were encountered: