Thinking that the inner query should not have an :in clause. It must inherit outer bindings from the outer query (with the subquery removed).
Alternatively, perhaps the inner query could have an :in but only to allow another inner query.
An inner query must be the final argument to an :in clause.
Arguments to q must match all non-query args to the :in clause.
By default, aggregate bindings are labeled as: the aggregate function name; a hyphen; the variable name the aggregate is calculated from. So (count ?child) is labeled: ?count-child. The :as keyword would rename this.
Subqueries are currently possible by piping the results of one query into the next:
This works efficiently, as it is only 2 queries, with the bindings of the first query being lazily consumed by the second.
However, this is difficult to follow. After some discussion with @marioaquino we're thinking that the following may work as a syntax:
Things to note:
:in
clause. It must inherit outer bindings from the outer query (with the subquery removed).:in
but only to allow another inner query.:in
clause.q
must match all non-query args to the:in
clause.(count ?child)
is labeled:?count-child
. The:as
keyword would rename this.