Fork me on GitHub
#datomic
<
2016-07-19
>
jjunior13004:07:04

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.

lockdown19:07:12

for writes, one should expect performance to be equal or lower to sqlite correct? since datomic serializes all writes just as sqlite does