Skip to content

Joins with a hierarchical projection (includes) #288

Description

@samwillis

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))})})

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions