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 datomic-play.core | |
(:use [datomic.api :only [db q] :as d]) | |
(:require [clojure.core.logic :as l] | |
[clojure.pprint :as pp])) | |
(def uri "datomic:dev://localhost:4334/hello") | |
(defprotocol IUnifyWithDatum | |
(unify-with-datum [u v s])) |
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
;; I could have used a closed dispatch (aka cond) but you may find this version more enjoyable | |
;; the spec format is the one provided by BG | |
(defprotocol Selector | |
(-select [s m])) | |
(defn select [m selectors-coll] | |
(reduce conj {} (map #(-select % m) selectors-coll))) | |
(extend-protocol Selector |
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
;; Datomic example code | |
;; | |
;; The extent of entity ?x is all datoms that are about ?x. | |
;; Drop this into your rules. | |
;; | |
;; Demonstrates | |
;; | |
;; 1. recursive query (extent calls itself) | |
;; 2. disjunction (different extent bodies are ORed) | |
;; 3. component attributes (e.g. your arm is a component, your brother isn't) |
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
#console { | |
height: 820px; | |
background: #eee; | |
margin: 10px; | |
border-radius: 5px; | |
-moz-border-radius: 5px; | |
border: 1px solid #aaa; | |
} | |
#console div.jquery-console-inner { |
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
;; lein settings | |
(defproject foo "1.0.0-SNAPSHOT" | |
:description "Test App" | |
:dependencies [[com.datomic/datomic "0.1.2678"] | |
[frinj "0.1.2" :exclusions [org.clojure/clojure]]]) | |
;; load libs | |
(use 'frinj.core 'frinj.calc) | |
(frinj-init!) | |
(use '[datomic.api :only (q db) :as d]) |
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
(use '[datomic.api :only [db q] :as d]) | |
;; DB setup | |
(def schema | |
[{:db/id #db/id[:db.part/db] | |
:db/ident :site/url | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db.install/_attribute :db.part/db} | |
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
;; this code valid as of build 3084 | |
;; in-memory example database | |
(use '[datomic.api :only (db q) :as d]) | |
(def uri "datomic:mem://test") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
;; example schema | |
(d/transact conn [{:db.install/_attribute :db.part/db, |
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
user=> @(d/transact conn | |
[{:db/id #db/id[:db.part/db] | |
:db/ident :audit/user | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db/index true | |
:db.install/_attribute :db.part/db}]) |
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
;; groovy-datomic example (https://github.com/jeffbrown/groovy-datomic) in Clojure | |
(use '[datomic.api :only (q db) :as d]) | |
(def uri "datomic:mem://comics") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
(d/transact | |
conn | |
[{:db/id #db/id[:db.part/db] | |
:db/ident :issue/comic |
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
(use '[datomic.api :only [db q] :as d]) | |
(def schema | |
[{:db/doc "A persons name" | |
:db/id #db/id[:db.part/db] | |
:db/ident :name | |
:db/valueType :db.type/string | |
:db/cardinality :db.cardinality/one | |
:db.install/_attribute :db.part/db} | |