Select direct child nodes
Hi,
I am trying to select all direct child nodes relative to the current position in hierarchy (using coreNode.id) in CategoryPage with the following query:
SELECT * FROM nodes WHERE ancestors.id ='category:${coreNode.id}'
It does select nodes, but some of those that are visible in hierarchy are not selected by the query, as well as it pulls in nodes that are not direct children of the coreNode, but nested deeper (as far as I understand, used selector looks for any match).
How can we extract all direct children nodes in CategoryPage relative to where you are currently in it?
arthur_- You can use depth with your current query, You just need to know the current coreNode depth e.g your core node depth is 1, you can pass depth 2 in your query.
SELECT title FROM nodes WHERE ancestors.id ='category:${coreNode.id}' AND depth = 2
arthur_- Below is the more exact query, you can use parent.id to get the exact result.
SELECT * FROM nodes WHERE parent.id = 'category:${coreNode.id}' ORDER BY position ASC
The parent.id always fetch the one level down nodes.
Here is the documentation https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&collection=nodes#constraints-parent.id