[SOLVED] Exclude a page from query

Pages with book notes have property type:: book. I have a template to create book page, so of course it too has that property.

To just get a list of books without the Template page, I compiled this:

{:title [:h3 "Books read"]
 :query [:find (pull ?b [*])
     [?b :block/properties ?prop]
     [(get ?prop :type) ?type]
     [(= ?type "book")]
     (not [?b :page "templates"])

Unfortunately, in table lay-out the list only shows the table headings but no list with titles.
What amendment do I need to make to the syntax?

I don’t understand your question?
What are you seeing and what are you trying to see?

@Siferiax a simple query {{query (property type book)}} gives me this output:


That is what I want to see, ideally sorted alphabetically (A @ top, Z @ bottom), but without the Templates page.

So, I tried to compile an advanced query, as shown in my OP. But then the output is this:


which, besides the headings, shows nothing, nada, zilch, niks.

You mean pages that contains blocks that have the property, right?

In that case have you tried:

{{query (and (property :type book) (not (property :template)))}}

or, if you want to exclude blocks from the page Templates specifically:

{{query (and (property :type book) (not (page [[Templates]])))}}


Thanks for jumping in :grinning:

I had to modify that slightly: {{query (and (property :type book) (not (page Templates)))}}, which then gives me what I want.

Is there a way to sort the rendered list alphabetically (titles starting with A at the top, those with Z at the bottom), or would I then need an advanced query?

By default you should see the results (blocks) grouped by page and the pages are sorted alphabetically.

And in table view you should have both a “Block” and a “Page” columns that can be used to sort alphabetically by blocks and pages name respectively.

Yep, that works indeed! Thanks for your help.
I have marked your OP as the solution.

1 Like

Hi guys,

is there a possibility to exclude one specific page from every query, without make it manuelly in every query? Maybe by a define specific property on this page, like exclude a page from graph (page property: exclude-from-graph-view:: true)?

Yes. We can exclude a specific property (value). But would still need to add that exclusion to each query.