The data shown in a user interface if often hierarchical (projects -> issues -> comments)
The joins supported by Tanstack DB are SQL like joins where the resulting rows are flat, however users will often what to project to a hierarchical structure to render in the UI.
The proposed syntax is to use subqueries in the select clause:
constprojects=newQuery.from({project: projectsCllctn}).where(....).select(({ project })=>({project,issues: newQuery.from({issue: issuesCllctn}).where(({ issue })=>eq(issue.projectId,project.id)).select(({ issue })=>({
issue,comments: newQuery.from({comment: commentsCllctn}).where(({ comment })=>eq(comment.issueId,issue.id))})})
The data shown in a user interface if often hierarchical (projects -> issues -> comments)
The joins supported by Tanstack DB are SQL like joins where the resulting rows are flat, however users will often what to project to a hierarchical structure to render in the UI.
The proposed syntax is to use subqueries in the
selectclause: