Matt's Roof Garden

Powered by 🌱Roam Garden

October 7th, 2021

useful datalog queries

Find pages edited today

{
  let ancestorrule=`[ 
     [ (ancestor ?b ?a) 
          [?a :block/children ?b] ] 
     [ (ancestor ?b ?a) 
          [?parent :block/children ?b ] 
          (ancestor ?parent ?a) ] ] ]`;

  let references = window.roamAlphaAPI.q(`[
    :find ?title
    :in $ ?start_of_day %
    :where
    [?page :node/title ?title]
    (ancestor ?block ?page)
    [?block :edit/time ?time]
    [(> ?time ?start_of_day)]
  ]`, new Date().setHours(0, 0, 0, 0), ancestorrule);

  references.map(
    (data, index) => {return `${data[0]}`;});
}

"What does it mean to be a boyfriend/girlfriend to you?"