Created
October 3, 2020 03:25
-
-
Save wavejumper/fd1fa56ac2f4ec2d516fb07b49641097 to your computer and use it in GitHub Desktop.
cljspad + datascript
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
(require '[datascript.core :as d]) | |
;; Example from datascript README | |
;; https://github.com/tonsky/datascript | |
(def schema {:aka {:db/cardinality :db.cardinality/many}}) | |
(def conn (d/create-conn schema)) | |
(d/transact! conn [ { :db/id -1 | |
:name "Maksim" | |
:age 45 | |
:aka ["Max Otto von Stierlitz", "Jack Ryan"] } ]) | |
;; Implicit join, multi-valued attribute | |
(def query-result | |
(d/q '[ :find ?n ?a | |
:where [?e :aka "Max Otto von Stierlitz"] | |
[?e :name ?n] | |
[?e :age ?a] ] | |
@conn)) | |
(prn query-result) | |
(write-output (str "Result is: " (pr-str query-result))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment