Advanced query that excludes blocks with queries

I’m trying to count the number of blocks in a parent block but the count returns 3 instead of two.
I fear it is counting the query block but I was unable to exclude it from the query…

## Dev-prop2
	- Jira: `timeout: write`
		- [[C_1_1_111_DataGather_Something_SelfService_functional_CheckingSomething]]
		- [[C_2_2_222_Info_Something_SelfService_functional_CheckingSomething]]
		- query-table:: false
		  {:title "Children blocks count of parent block"
		   :inputs [:parent-block]
		   :query  [:find (count ?b)
		            :in $ ?parent-block
		               [?b :block/parent ?parent-block]

Any ideas?


  • Yes, that counts also the query block, since it is a child of the same parent. Here is one way to exclude all the child-blocks that contain advanced queries:
    [?b :block/content ?content]
    (not [(clojure.string/includes? ?content "_QUERY")])
  • However, normally it shouldn’t be needed to mix a query with the data it applies on. You are probably trying to achieve something different, which should be possible in a more elegant way.

Thanks @mentaloid that solved it!