List block property in pages with certain page-tags


I have several pages:
page 1

tags:: tag1
- q:: question 1
- model:: model x
- ...

page 2

tags:: tag2
- q:: question 2

page 3

tags:: tag1
- q:: question 3

Can you help me to write a query to get the contents in block-property q, and only query for pages with page-tags of tag1.
The result should be:

title q
page 1 question 1
page 3 question 3
  • Create a query like this one:
     :query [:find (pull ?b [*])
       [?tag :block/name "tag1"]
       [?p :block/tags ?tag]
       [?b :block/page ?p]
       [?b :block/properties ?props]
       [(get ?props :q)]
  • Click on the top-right to Switch to table view
  • Click on the nearby cogwheel to hide unwanted columns
  • Click on the column’s title you want to sort by
  • Here is the result:

Thank you very much. It solved my problem!

And if I want to list the contents of several properties, what should I do?

I tried (or [(get ?props :q)] [(get ?props :model)]), but it looks like:

title q model
page 1 question 1
page 3 question 3
page 1 model x

My desired outcome is:

title q model
page 1 question 1 model x
page 3 question 3

Each row in the table represents one block. Apparently page 1 contains multiple blocks, including one with property q:: question 1 and one with property model:: model x, therefore it has two entries in the table. The easiest way to merge the two rows (like in your desired outcome) is to merge those two blocks. In other words, to put all the properties in the same block.