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

[FEATURE]: select() field types? #531

Closed
shinebayar-g opened this issue Apr 29, 2023 · 4 comments
Closed

[FEATURE]: select() field types? #531

shinebayar-g opened this issue Apr 29, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@shinebayar-g
Copy link

Describe want to want

For the following example, is it possible to determine which fields are available to use inside select({}) function?

const upperCaseNames /* : { id: number; name: string }[] */ = await db
  .select({
    id: users.id, // <-- ?
    name: sql<string>`upper(${users.fullName})`,
  })
  .from(users);

If not, is it on the roadmap or is it by design as it is?

@shinebayar-g shinebayar-g added the enhancement New feature or request label Apr 29, 2023
@dankochetov
Copy link
Contributor

Not really, because the .select() shape can be a lot more complex than just the table fields - it can have nested objects, keys with any names, SQL expressions, fields from multiple tables with joins etc.
We are currently working on a separate API for conventional querying, and it will work exactly like this, with autocomplete for all the columns - #504

@brunolau
Copy link

Hi, any info on this API? The issue tracking this seems to be marked as done, but I can't find it anywhere.

@relsunkaev
Copy link

Hi, any info on this API? The issue tracking this seems to be marked as done, but I can't find it anywhere.

It's the relational query API

@Angelelz
Copy link
Collaborator

Can this issue be closed? Relational queries are a thing now.

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

No branches or pull requests

5 participants