How are people pulling collections in cloud?

Since the find-coll … expression and pull-many is not available, are people using recursive pulls? I’m using ions and was a bit surprised that find-coll was not available in the :ion server type.


If I understand you correctly, you can use pull syntax in a recursive way. Consider the following schema:

{:pull-request/author   {:db/valueType :db.type/ref}
 :pull-request/comments {:db/valueType :db.type/ref
                         :db/cardinality :db.cardinality/many}
 :comment/author        {:db/valueType :db.type/ref}}

You could then

(require '[datascript.core as ds)
(def test-db ...)

(ds/q '[:find [(pull ?e [* {:pull-request/comments [* {:comment/author [*]}]}]) ...]
        [?e :pull-request/title]]
;; => [{:db/id 1,
;;      :pull-request/author #:db{:id 2},
;;      :pull-request/comments
;;      [{:db/id 3,
;;        :comment/author
;;        {:db/id 5, :user/avatar "", :user/name "Christian"},
;;        :comment/text "A question"}
;;       {:db/id 4,
;;        :comment/author
;;        {:db/id 2, :user/avatar "", :user/name "Magnar"},
;;        :comment/text "A reply"}],
;;      :pull-request/title "A pull request"}]

Note: I’ve tested the above with Datascript and not Datomic, but I think the behavior is the same.

1 Like

Thanks @teodorlu. I’d made an assumption a while ago about find-coll which was incorrect. I was using

 [(pull ?e [* {:pull-request/comments [* {:comment/author [*]}]}]) ...]

when in fact

(pull ?e [* {:pull-request/comments [* {:comment/author [*]}]}]) 

does the job.

Glad to hear it helped!