Skip to content

Instantly share code, notes, and snippets.

@dfuenzalida
Created June 28, 2020 21:14
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 dfuenzalida/4aa6ce9ef27074b8603108fc1594a45a to your computer and use it in GitHub Desktop.
Save dfuenzalida/4aa6ce9ef27074b8603108fc1594a45a to your computer and use it in GitHub Desktop.
(ns datomic-shortcut.core
(:require [datomic.api :as d]))
(def db-uri "datomic:mem://foo")
(comment
(d/create-database db-uri)
(def conn (d/connect db-uri))
)
(def movie-schema [{:db/ident :movie/title
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "The title of the movie"}
{:db/ident :movie/genre
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "The genre of the movie"}
{:db/ident :movie/release-year
:db/valueType :db.type/long
:db/cardinality :db.cardinality/one
:db/doc "The year the movie was released in theaters"}])
;; @(d/transact conn movie-schema)
(def first-movies [{:movie/title "The Goonies"
:movie/genre "action/adventure"
:movie/release-year 1985}
{:movie/title "Commando"
:movie/genre "thriller/action"
:movie/release-year 1985}
{:movie/title "Repo Man"
:movie/genre "punk dystopia"
:movie/release-year 1984}])
;; @(d/transact conn first-movies)
(def all-titles-q '[:find ?movie-title
:where
[_ :movie/title ?movie-title]])
;; (d/q all-titles-q (d/db conn))
;; => #{["Commando"] ["The Goonies"] ["Repo Man"]}
(defproject datomic-shortcut "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.0"]
[com.datomic/datomic-free "0.9.5697"]]
:main ^:skip-aot datomic-shortcut.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment