This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-19
Channels
- # admin-announcements (2)
- # aws-lambda (3)
- # beginners (66)
- # boot (61)
- # cider (1)
- # cljs-dev (17)
- # clojure (100)
- # clojure-austin (4)
- # clojure-brasil (1)
- # clojure-canada (8)
- # clojure-quebec (6)
- # clojure-russia (48)
- # clojure-sg (6)
- # clojure-spec (37)
- # clojure-uk (61)
- # clojure-ukraine (2)
- # clojurescript (80)
- # core-async (13)
- # cursive (20)
- # datascript (37)
- # datomic (2)
- # defnpodcast (4)
- # emacs (5)
- # funcool (3)
- # hoplon (11)
- # jobs (7)
- # juxt (26)
- # lein-figwheel (48)
- # leiningen (3)
- # luminus (3)
- # om (34)
- # om-next (5)
- # onyx (5)
- # protorepl (6)
- # re-frame (10)
- # reagent (9)
- # rethinkdb (16)
- # ring-swagger (5)
- # spacemacs (14)
- # specter (54)
- # untangled (36)
- # vim (75)
- # yada (1)
Can someone help me make Datomic schemas for use with DataScript? At least for the ones with => Schema for DataScript
(def Name
Str)
(def FundamentalUnit
(enum "K" "s" "bit"
"dollar" "cd" "kg"
"A" "m" "mol"))
(def FundamentalUnits
{(conditional FundamentalUnit
FundamentalUnit
:else (enum "bits" "<<IMAGINARY_UNIT>>" "oz"
"lb" "1000inch"))
Int})
(def Unitless
{})
(def Unit
[Name {:v Num
:u (conditional empty?
Unitless
FundamentalUnits)}])
(def PhysicalQuantity
{:amount pos?
:unit Unit})
(def Transaction
{(enum :production :consumption) PhysicalQuantity
:timestamp DateTime})
=> Schema for DataScript
;; most important piece of data for what I'm working on.
(def TransactionHistory
'(Transaction))
=> Schema for DataScript
(def Dimension
[(conditional empty?
Unitless
FundamentalUnits)
Name])
The units are based on https://github.com/martintrojer/frinj/blob/master/resources/units.edn
I'm studying to understand writing Datomic schemas.@jjunior130: I don’t understand your syntax, can you show what you expect your data to look like?
@tonsky: Was using the syntax of https://github.com/plumatic/schema The data would look something like:
;; List of transactions
(list
;; Getting money
{:production {:amount 15
:unit ["USD" {:v 1
:u {"dollar" 1}}]}
:timestamp "01-03-2016"}
;; Spending money
{:consumption {:amount 5
:unit ["USD" {:v 1
:u {"dollar" 1}}]}
:timestamp "01-08-2016"}
;; burning Calories
{:consumption {:amount 500
:unit ["Calories" {:v 20934/5
:u {"m" 2, "s" -2, "kg" 1}}]}
:timestamp "01-15-2016"}) ;; etc
Don't know where to start. I think I should start writing a Datomic schema for (datascript.core/create-conn <insert-schema>)
ok, I’d recommend you start with https://www.youtube.com/watch?v=bAilFQdaiHk
I saw that video, I'll rewatch it.
unfortunately, DataScript has no tutorials/docs at the moment, I recommend everybody to learn from Datomic resources instead
Yeah that's what i've been doing lately. Reading http://docs.datomic.com/schema.html to learn writing the schema I need, if I even need a schema.
{ :production/amount {}
:production/unit { :db/valueType :db.type/ref }
:timestamp {}
:consumption/amount {}
:consumption/unit { :db/valueType :db.type/ref }
:unit/name {}
:unit/v {}
:unit/u {} }
{ :production/amount {}
:production/unit { :db/valueType :db.type/ref }
:timestamp {}
:consumption/amount {}
:consumption/unit { :db/valueType :db.type/ref }
:unit/name { :db/unique :db.unique/identity }
:unit/v {}
:unit/u {} }
:u is the dimension https://en.wikipedia.org/wiki/List_of_physical_quantities and :v is the factor to multiply by to get the SI Unit value
Nice, DataScript fits nicely with Specter then. https://github.com/nathanmarz/specter
Thank you very much. This will help me a lot.
yes, from what I understand datascript.core
for transact and posh.reagent
for querying.
also there’s a webinar where I build an app http://vimeo.com/114688970
cool! will check them out. examples are good for reference.
posh also has transact
and as I understand, it batches transactions across subscriptions lifecycle
@dhucerbin: yeah you're right, I forgot about that
;; Posh's transact
(defn transact! [poshdb-or-conn txs]
(datascript.core/transact!
(if (datascript.core/conn? poshdb-or-conn)
poshdb-or-conn
(posh.stateful/poshdb->conn poshdb-or-conn))
txs))