Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appending references to arrays #225

Open
zeitstein opened this issue Nov 12, 2021 · 1 comment
Open

Appending references to arrays #225

zeitstein opened this issue Nov 12, 2021 · 1 comment

Comments

@zeitstein
Copy link

Directly appending the referenced :db/id works, but not the usual {:db/id ...} syntax; same for :db/ident and :id. Example initial data:

[{:db/ident 0 :child [{:db/ident 1}]}
 {:db/ident 1 :data "1"}]

Transacting the following doesn't work:

[{:db/ident 2 :data "2"}
 {:db/ident 0 :child+ {:db/ident 2}}]

;; inserted into the array as:
;; #datom [:tg/node-25760 :tg/first #:db{:ident 2} 2 true]

This works:

[{:db/ident 2 :data "2" :db/id :tg/node-2}
 {:db/ident 0 :child+ :tg/node-2}]

But not temporary ids:

[{:db/id -1 :db/ident 3 :data "3"}
 {:db/ident 0 :child+ -1}]

;; inserted into the array as
;; #datom [:tg/node-25728 :tg/first -1 2 true]
@zeitstein
Copy link
Author

Clearer examples. None of the below work:

  ;; initial
  (d/transact conn [{:id 1}
                    {:id 0 :array [{:id 1}]}])

  (d/transact conn [{:id "new"}
                    {:id 0 :array+ {:id "new"}}])

  (d/transact conn [{:id "new"}
                    {:id 0 :array+ [:id "new"]}])

  (d/transact conn [{:id "new2"}
                    {:id 0 :array+ "new2"}])

  (d/transact conn [{:id "new3" :db/id -1}
                    {:id 0 :array+ -1}])

The only thing that works is:

  (d/transact conn [{:db/id :tg/node-1}
                    {:db/id :tg/node-0 :array [{:db/id :tg/node-1}]}])

  (d/transact conn [{:db/id :tg/node-new}
                    {:db/id :tg/node-0 :array+ :tg/node-new}])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant