Datomic's idents (attribute :db/ident) allow you to assign programmatic names to entities. You can then use those programmatic names where you would otherwise have to use an entity id, e.g.
Idents can be used instead of entity ids in the following API calls:
- as the sole argument to entity
- in the e and v positions of assertions and retractions passed to transact and with
- in the e and v positions of a query
There are some situations where Datomic cannot know that a piece of data is an ident. For example, Datomic does not know the semantics of database functions written by you. If you need to convert between idents and entity ids in your own code, you can use the ident and entid methods on the Database class.
Idents should be used for two purposes: to name schema entities, and to implement enumerated tags. Both of these uses are demonstrated in the introductory tutorial. To support these usages, idents have two unique characteristics:
- Idents are designed to be extremely fast and always available. All idents associated with a database are stored in memory in every Datomic transactor and peer.
- When you navigate the entity API to a reference that has an ident, the lookup will return the ident, not another entity.
These characteristics also imply situations where Idents should not be used.
- Idents should not be used as unique names or ids on ordinary domain entities. Such entity names should be implemented with a domain-specific attribute that has the :db/unique property set.
- Idents should not be used as names for test data. (You real data will not have such names, and you don't want test data to handled differently than the real data it simulates.)