Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can't directly persist multi-dimensional lists/vectors but you can use a linking entity to accomplish something similar:</p> <pre><code>;; sample attributes [{:db/id #db/id[:db.part/db] :db/ident :some/ref-value :db/valueType :db.type/ref :db/isComponent true :db/cardinality :db.cardinality/many :db.install/_attribute :db.part/db} {:db/id #db/id[:db.part/db] :db/ident :some/list-value :db/valueType :db.type/string :db/cardinality :db.cardinality/many :db.install/_attribute :db.part/db}] ;; [["a" "b" "c"]["d" "e" "f"]] [{:db/id #db/id[:db.part/user -1] :some/list-value ["a" "b" "c"]} {:db/id #db/id[:db.part/user -2] :some/list-value ["d" "e" "f"]} {:db/id #db/id[:db.part/user] :some/ref-value [#db/id[:db.part/user -1] #db/id[:db.part/user -2]]}] </code></pre> <p>Note that you can use negative numbers to link entities together. They will be replaced by real entity ids when you transact them.</p> <p><strong>EDIT</strong>: Starting with version 0.8.4020, Datomic supports nested <a href="http://blog.datomic.com/2013/06/component-entities.html" rel="noreferrer">component entities</a> (containment relationships specified by <code>:db/isComponent</code>) as part of the transaction data. e.g.</p> <pre><code> ;; [["a" "b" "c"]["d" "e" "f"]] [{:db/id #db/id[:db.part/db] :some/ref-value [{:some/list-value ["a" "b" "c"]} {:some/list-value ["d" "e" "f"]}]}] </code></pre> <p>The nested maps expand into two sub-entities, both created in the same partition as the container/parent entity. For a full code sample, see <a href="https://gist.github.com/a2ndrade/5820364" rel="noreferrer">https://gist.github.com/a2ndrade/5820364</a></p>
 

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