clojure - in datomic, how is it possible to find out what keys are available for reverse lookup? -


the following uses simplified datomic setup:

:account/user -> string :account/email -> ref  :email/name -> string :email/type -> keyword 

if have entity containing account information, easy know has email information

(keys <account entity>)  ;; => [:account/user :account/email]  (:account/email <account entity>)  ;; => <email entity> 

but on flipside, if @ keys of email entity, not know has linked account information.

(keys <email entity>)  ;; => [:email/name :email/type]  (:account/_email <email entity>)  ;; => <account entity> 

how 1 find out :account/_email valid key without trial , error?

to check if key valid can use:

(.containskey <email entity> :account/_email) ;; => true 

in order valid entity keys including reverse ones:

(.touch <email entity>) (keys (.cache <email entity>)) 

note (keys) called directly on entity returns forward keys.

tested on similar schema.

side note: apart

(:account/_email <email entity>) 

you can query accounts have linked specified email:

(q '[:find ?a :in $ ?e :where [?a :account/email ?e] ] (db conn) (:db/id <email entity>)) 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -