--- gitea: none include_toc: true --- # Queries ## Graph or Tree Queries can return results in 2 formats. A graph or a tree. Graphs results are a collection of records (nodes) and a collection of edges. This format is more useful for network visualization. The tree format is more straightforward as it returns a collection of records. Each record has a **_children** and a **_parents** field and the tree can continue upwards or downwards according to the depth you have requested. For example to request records with their children and their children's children: ```php $query->childrenDepth(2); ``` Maybe you only want to get a specific type of relationship: ```php $query->childrenDepth(2)->childrenFields(["categories"]); ``` ## Filters You can filter your query with the following format: ```php $query->filter(["field_operator" => "value"]); // example: $query->filter(["date_lt" => "2020-09-15"]); ``` Or filters are also available: ```php $query ->filter(["price_eqn" => 10]) ->orFilter(["title_regex" => "search", "slug_regex" => "search"]) ; ``` ## Operator List - regex - eq - ne - eqnum - neqnum - filter - eqtrue - eqfalse - netrue - nefalse - in: - innum - nin - ninnum - lt - lte - gt - gte - null - nnull - exists - nexists ## Example Get 10 posts from the sports category as a tree ```php $posts = $query ->filter([ "schema" => "posts", "children.categories.data.slug" => "sports", ] ) ->childrenDepth(1) ->limit(10) ->tree(); $posts->map(...)->toArray(); ```