Skip to content

Instantly share code, notes, and snippets.

View bobby's full-sized avatar

Bobby Calderwood bobby

View GitHub Profile
@bobby
bobby / keybase.md
Created May 15, 2018 17:28
keybase.md

Keybase proof

I hereby claim:

To claim this, I am signing this object:

(ns user
(:require [clojure.java.io :as io]
[datomic.api :as d]))
(defn order-schema []
(read-string (slurp (io/resource "schema.edn"))))
(defn start-datomic! [uri schema]
(d/create-database uri)
(let [conn (d/connect uri)]
@bobby
bobby / query.clj
Last active December 14, 2015 17:58
Query over datomic entities
(defn q-entities
"For a Datomic datalog query taking a Datomic db as its first source and returning only
entity ids, returns the corresponding entities."
[query & sources]
(map (comp (partial d/entity (first sources))
first)
(apply q query sources)))
(ns devnewb
(:require [datomic.api :as d :refer (db q)]
[clojure.data.generators :as gen]))
;; Make sure a free transactor is running at URI below
(def uri "datomic:free://localhost:4334/devnewb")
;; Caution!!! This happens on load!
(d/delete-database uri)
@bobby
bobby / datomic-helpers.clj
Created July 20, 2012 14:12
Some Datomic helpers I sometimes use with ring or pedestal-service apps
(ns datomic-helpers
(:require [datomic.api :as d]))
;;; Expose Datomic vars here, for convenience
;;; Ring middleware
(defn wrap-datomic
"A Ring middleware that provides a request-consistent database connection and
value for the life of a request."