Retrieving keyword from ID


#1

I have idents:

(def languages
[{:db/ident :language/EN}
{:db/ident :language/ZH}])

And I define the schema with a language attribute:

 . . .
 {:db/ident :user/language
 :db/valueType :db.type/ref           
. . .}

Then I put in a record:

(tx [{... :user/language :language/EN...}])

When I pull that record back, I get the ID:

{... :user/language #:db{:id 17592186045419}...}

And I want to turn that #:db{:id 17592186045419} into :language/EN (or something approximating that).


#2

Hi Blake,

You should be able to pull the :db/ident for the record to get the keyword ident you’re looking for (https://docs.datomic.com/cloud/best.html#use-pull-to-retrieve-attribute-values).


#3

Thanks, Marshall! I was looking right at it and couldn’t figure it out but I got it now. And for anybody who comes after:

(d/pull (db) [:db/ident] 17592186045418)

…where you replace “17592186045418” with your number. I think what was confusing me was the :db namespace. I kept thinking I needed :language.