Note that there are some explanatory texts on larger screens.

plurals
  1. PONesting structures With Datomic
    primarykey
    data
    text
    <p>Using Datomic, I'm trying to think of how can I nest a list within a list? </p> <p>An example Clojure data structure would be something (see <em>fig.1</em>). I know that Datomic has the notion of references (ex. in <em>fig.2</em>). But those just look like scalar types, not objects (per se). </p> <pre><code> [{:id 0, :symbol DDD, :company 3D Systems Corporation, :price-difference 1.3100000000000023, :event-list [{high 35.11, tickerId 0, WAP 34.491, open 35.07, date 20130426, count 3403, low 33.8, hasGaps false, close 34.53, field historicalData, volume 8667, type historicalData}]}] </code></pre> <p><em><strong>fig.1</em></strong></p> <pre><code> {:db/id #db/id[:db.part/db] :db/ident :district/region :db/valueType :db.type/ref :db/cardinality :db.cardinality/one :db/doc "A district region enum value" :db.install/_attribute :db.part/db} ;; district/region enum values [:db/add #db/id[:db.part/user] :db/ident :region/n] [:db/add #db/id[:db.part/user] :db/ident :region/ne] [:db/add #db/id[:db.part/user] :db/ident :region/e] [:db/add #db/id[:db.part/user] :db/ident :region/se] [:db/add #db/id[:db.part/user] :db/ident :region/s] [:db/add #db/id[:db.part/user] :db/ident :region/sw] [:db/add #db/id[:db.part/user] :db/ident :region/w] [:db/add #db/id[:db.part/user] :db/ident :region/nw] </code></pre> <p><em><strong>fig.2</em></strong></p> <p>[EDIT]</p> <p>Actually, I think I might have found the answer <a href="https://github.com/Datomic/day-of-datomic/blob/master/resources/day-of-datomic/schema.edn#L36">here</a>. I was going through the <a href="https://github.com/Datomic/day-of-datomic">Day-Of-Datomic</a> code base, and found the example below. But I'm still not clear on what explicitly ties the <strong><em>:comments</em></strong> namespace to the <strong><em>:comment/body</em></strong> (or <strong><em>:comment/author</em></strong>) namespace(s). Does Datomic just use convention to link <strong><em>:comments</em></strong> to <strong><em>:comment</em></strong> ? </p> <pre><code> ;; comments [{:db/id #db/id[:db.part/db] :db/ident :comments :db/valueType :db.type/ref :db/cardinality :db.cardinality/many :db/isComponent true :db.install/_attribute :db.part/db} {:db/id #db/id[:db.part/db] :db/ident :comment/body :db/valueType :db.type/string :db/cardinality :db.cardinality/one :db.install/_attribute :db.part/db} {:db/id #db/id[:db.part/db] :db/ident :comment/author :db/valueType :db.type/ref :db/cardinality :db.cardinality/one :db.install/_attribute :db.part/db}] </code></pre> <p><em><strong>fig.1</em></strong> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload