Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

facjure/atomic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Atomic

A tiny library on Datomic, with a declarative api for working with Facts, Schemas, and Rules.

Getting Started

For in-memory datomic, setup:

(db/connect-anonymously!)

Create a schema:

(schema/create
  [[:story/title "full title" :string :one :fulltext :index]
  [:story/url "story's permamnent url" :string :one :unique-identity :index]
  [:story/slug "a short title" :string :one]
  [:comments "a collection of comments" :ref :many :component]
  [:comment/body "comment 140 chars or less" :string :one]
  [:comment/author "comment author" :ref :one]])

Validate:

(schema/has-attribute? :story/title)

Create Facts:

(fact/add
  {:story/title "Datomic's 1.0 is released"
   :story/url "http://datomic.com/downloads/1.0"
   :story/slug "New, improved declarative api"
   :comment/author 17592186045425
   :comment/body "This is great!"})

Find Facts:

(query/find-all-by :story/title)
(query/find-changes 17592186045425)
>> {:author/name {:old nil, :new "Stu G"}, :author/email {:old nil, :new "[email protected]"}}
(query/find-all-by :story/title)
(query/find [:story/title] :story/url "http://datomic.com/downloads/1.0")

Queries:

(query/defquery
  '{:find [?title ?url]
    :in   [$ ?title]
    :where [[?a :story/title ?title]
           [?t :story/url ?url]]
    :values ["Clojure 2.0 announced", "http://clojure.org/downloads/2.0-beta"]})

Status

Atomic is currently in the design phase.

Clojars Project

Circle CI

License

© 2015-2016 Facjure, LLC.

Distributed under the Eclipse Public License, the same as Clojure.

About

a tiny library for datomic

Resources

License

Stars

Watchers

Forks

Packages

No packages published