Skip to content

Instantly share code, notes, and snippets.

@jonase
Created May 18, 2012 13:22
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 jonase/2725243 to your computer and use it in GitHub Desktop.
Save jonase/2725243 to your computer and use it in GitHub Desktop.
(def uri "datomic:mem://testdb")
(d/create-database uri)
(def conn (d/connect uri))
;; The schema
(def s [{:db/id #db/id[:db.part/db]
:db/ident :testdb/test
:db/valueType :db.type/boolean
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}])
(d/transact conn s)
;; Add two facts to the db
(d/transact conn [[:db/add #db/id[:db.part/db] :testdb/test true]
[:db/add #db/id[:db.part/db] :testdb/test false]])
(defn query [b]
(q '[:find ?e
:in $ ?b
:where
[?e :testdb/test ?b]]
(db conn) b))
(query true) ;; OK, #<HashSet [[63]]>
(query false) ;; Throws an exception:
;; Unable to find data source: $38171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment