Created
May 18, 2012 13:22
-
-
Save jonase/2725243 to your computer and use it in GitHub Desktop.
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
(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