V2 - Understanding queries lua and help to migrate old requests

Hello,

From my understanding (and tests I’ve done), it seems this can only request the field “tag” to print pages.

${query[[from index.tag ...

It is no possible to query directly the page name ?

With something like :

${query[[from index.page ...

Because in V1 I used this kind of query a lot:

Here I print all the pages within “work/” at level 1 but without the sub-sub-page.

page where name =~ "work/[^/]+$" render [[Library/Core/Query/Page]] order by name

work/topicA (printed)
work/topicA/customer-X (Not Printed)

How can I migrate this kind of request with the V2 method ?

Thanks for your help.

${query[[
  from index.tag "page"
  where string.match(name, "Work/[^/]+$")
  order by name
  select "[[" .. name .. "]]"
]]}
2 Likes

where string.match(name, "Work/[^/]+$") is the key.

Thanks for the help. Lua/new requests was a bit confusing to me, but seems to be becoming more and more obvious.

Lua protip: where name:match("Work/[^/]+$") should also work and is slightly shorter.

1 Like