Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Cloud by
edited by

I could not find how to do it serching the documentation, if you could point out where, it'd be appreciated.

Example: with the following data (excerpted from an ExceptionInfo):
{:data [:db/add -9223301668109517911 112 nil], :db/error :db.error/nil-value, ...}
What we'd like to know is which :db/ident has the id 112.
Is there a way to do it?

1 Answer

+1 vote
by
selected by
 
Best answer

I use these three functions to get the id from a name, name from an id and the entity.

(defn ident-name [conn eid]
  (ffirst  (d/q '[:find ?v :in $ ?eid :where [?eid :db/ident ?v]] (d/db conn) eid)))

(defn ident-id [conn ident]
  (ffirst  (d/q '[:find ?eid :in $ ?v :where [?eid :db/ident ?v]] (d/db conn) ident)))

(defn pull-eid [conn eid]
  (ffirst  (d/q '[:find (pull  ?eid [*]) :in $ ?eid ] (d/db conn) eid)))
by
Thank you very much, these worked perfectly!
...