Created
December 12, 2015 06:48
-
-
Save c-garcia/82a7b99807eb8fe7c2ed to your computer and use it in GitHub Desktop.
Datascript sample
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
(ns clj-wb.ds | |
(:require [datascript.core :as d])) | |
(let [schema {:tags {:db/cardinality :db.cardinality/many}} | |
conn (d/create-conn schema)] | |
(d/transact! conn [{:db/id 1 | |
:name "John Doe" | |
:status :ok | |
:tags ["cplusplus" "java"]} | |
{:db/id 2 | |
:name "Mark Doe" | |
:status :ko | |
:tags ["clojure" "python" "ruby"]} | |
{:db/id 97 | |
:address "Baker Street, 14" | |
:who 1} | |
{:db/id 98 | |
:address "Pedroneras, 24" | |
:who 2}]) | |
;; db/id is the datom entity. person -> db/id | |
(d/q '[:find ?person ?name ?address | |
:where | |
[?person :name ?name] | |
[?data :who ?person] | |
[?data :address ?address]] | |
@conn)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment