Last active
December 30, 2015 08:38
-
-
Save statonjr/7803468 to your computer and use it in GitHub Desktop.
Datomic helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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