datascript

Nik 2024-03-24T14:47:53.728209Z

Hi, I'm want to get records from the latest database where :date is greater than max date of old database.

(d/q '[:find
           [(pull ?t2 [*]) ...]
           :in $old $new
           :where
           [(d/q [:find (max ?d) .
                  :where [?t :date ?d]]
                 $old)
            ?max]
           [$new ?t2 :date ?d2]
           [(dev.nickdex/after? ?d2 ?max)]]
         sms-source
         @sms-source-conn)
but when I use pull in :find (see commented code), I get error
Cannot read field "pull_patterns" because the return value of "clojure.lang.IFn.invoke(Object)" is null
Right now i'm doing it in following way but i'm not sure if this is the idiomatic way
(->>
    (d/q '[:find
            [?t2 ...]
           :in $old $new
           :where
           [(d/q [:find (max ?d) .
                  :where [?t :date ?d]]
                 $old)
            ?max]
           [$new ?t2 :date ?d2]
           [(dev.nickdex/after? ?d2 ?max)]]
         sms-source
         @sms-source-conn)
    (map #(d/pull @sms-source-conn '[*] %))
    (sort-by :date)
    reverse
    #_(take 5))

✅ 1
Nik 2024-03-24T15:36:16.776769Z

oh I figured it out. You have to pass the src-value in pull expression as well in case of multiple database