Skip to content
View log_size.clj
;; bin/run log_size.clj DB-URI t
;; Estimates the total in-memory size of all log entries from t to end of data.
;; Scans log from t to the end, so run against a backup instead of production if possible!
(require
'[clojure.edn :as edn]
'[clojure.pprint :as pp]
'[datomic.api :as d]
'[datomic.memory-size :as size])
View crosscheck_tx_instants.clj
;; bin/run crosscheck_tx_instants.clj DB-URI t
;; This program walks the log to find txInstants
;; and then finds the same instants in the indexes.
;; Scans log from t to the end, so run against a backup instead of production if possible!
(require
'[clojure.edn :as edn]
'[clojure.pprint :as pp]
'[datomic.api :as d])
View log_as.clj
;; bin/run log_as.clj DB-URI t attr
;; This program walks the log extracting datoms about a particular attribute.
;; Reveals domain data, but only about that one attribute.
;; Scans log from t to the end, so run against a backup instead of production if possible!
(require
'[clojure.edn :as edn]
'[clojure.pprint :as pp]
'[datomic.api :as d])
View log_ts.clj
;; This program walks the entire log extracting information about t
;; Does not reveal any domain data.
;; Scans entire log, so run against a backup instead of production if possible!
(require '[datomic.api :as d]
'[clojure.pprint :as pp])
(defn max-t
"Returns the maximum t mentioned in a collection of datoms"
[datoms]
(reduce
View entity-summary.clj
(require '[datomic.api :as d])
(defn entity-summary
"Returns a map with
:eavt vector of all eavt history datoms with eid
:log vector of all log entries containing those datoms"
[conn eid]
(let [log (d/log conn)
db (d/db conn)
hist (d/history db)
View interactive-query-dev.clj
(def zap (partial + 1))
(d/q '[:find ?b
:in ?a
:where [(user/zap ?a) ?b]]
1)
;; #{[2]}
(def zap (partial + 2))
View Nil Finder
(ns user)
(def app
"Intenal Helper"
(fnil conj []))
(defprotocol PathSeq
(path-seq* [form path] "Helper for path-seq"))
(extend-protocol PathSeq
View how-many-datoms.clj
(require
'[datomic.api :as d])
(defn how-many-datoms-did-tx-make?
"Return the number of datoms created by transaction at
time t, defaulting t to the most recent transaction."
([conn] (how-many-datoms-did-tx-make? conn (-> conn d/db d/basis-t)))
([conn t]
(some-> (d/log conn) (d/tx-range t nil) first :data count)))
View schema_history.clj
;; Complete schema history for a live Datomic database.
(require
'[clojure.pprint :as pp]
'[clojure.set :as set]
'[datomic.api :as d])
;; fill this in with your own database connection
(def uri "datomic:dev://localhost:4334/my-db")
(def conn (d/connect uri))
(def db (d/db conn))
View entity map expansion
(require '[datomic.api :as d])
(def uri "datomic:mem://foo")
(d/create-database uri)
(def conn (d/connect uri))
@(d/transact conn [{:db/id (d/tempid :db.part/db)
:db/ident :card-1-reference
:db/valueType :db.type/ref
:db/isComponent true
Something went wrong with that request. Please try again.