Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on nested queries. #14

Open
nicoabie opened this issue Jan 30, 2024 · 1 comment
Open

Question on nested queries. #14

nicoabie opened this issue Jan 30, 2024 · 1 comment

Comments

@nicoabie
Copy link

The example shows a one to many relationship between users and posts.

What happens if the relationship is one to one like user and work_address? where the latest instead of being an array should be a single object?

@wsporto
Copy link
Owner

wsporto commented Jan 30, 2024

The documentation shows an example of a one-to-one relationship between customers and addresses in the section "One To One". https://typesql.pages.dev/guides/nested-query-result/

In that case each user will have a single address object as shown below:

/* result type
{
  id: number,
  full_name: string,
  address_id: number,
  address: {
    id: number,
    address: string,
    zip_code: string,
    city: string,
    state: string
  }
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants