Skip to content

Instantly share code, notes, and snippets.

@statonjr
Last active December 30, 2015 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save statonjr/7803468 to your computer and use it in GitHub Desktop.
Save statonjr/7803468 to your computer and use it in GitHub Desktop.
Datomic helpers
(ns com.larrystaton.datomic
(:require [datomic.api :as d]))
;; (find-entity-id :person/name "Larry Staton" (d/db conn))
(defn find-entity-id
"Query Datomic for the entity ID with ATTR and VAL in DBVAL"
[attr val dbval]
(ffirst
(d/q '[:find ?e
:in $ ?a ?v
:where [?e ?a ?v _]]
dbval
attr val)))
;; (reveal 12345678909876 (d/db conn))
(defn reveal
"Touch the ENTITY-ID in DBVAL to reveal the attributes and values"
[entity-id dbval]
(d/touch (d/entity dbval entity-id)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment