Adding a query column with the days count between :block/scheduled and :today

Hi!

I am able to add a column by adding a new property to block/properties using the update and assoc method using :result-transform in query that pulls all block properties ((pull ?block [*])) like this:

:result-transform (fn [result]
(sort-by (fn [b]
(get b :block/scheduled)) result)
(map (fn [m] (update m :block/properties (fn [u] (assoc u :scheduled (get-in m [:block/scheduled]) ) ) ) ) result ) )

→ In this example, I am able to create a column called “scheduled” which shows the value of :block/scheduled

However, when trying to calculate the count of days between :today and :block/scheduled, logseq won’t display/add any column for it:

:result-transform (fn [result]
                      (map (fn [m]
                             (let [days-difference (dayjs () .diff (dayjs (get-in m [:block/scheduled])) 'day')]
                               (assoc m :days-difference days-difference)))
                           result))

→ My expectation with this code: a new column named days-difference would appear, at least.

  • Doesn’t logseq support let?
  • How about dayjs()?

If these methods doesn’t work, how should I approach this?
Thank you.

  • dayjs is javascript
    • that’s what the js part means
  • but :result-transform uses clojurescript, which:
    • supports let
    • but not dayjs

Since dayjs fails, the whole query does.

No easy way in my mind.