drizzle-orm
drizzle-orm copied to clipboard
[FEATURE]: select() field types?
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?
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
Hi, any info on this API? The issue tracking this seems to be marked as done, but I can't find it anywhere.
Hi, any info on this API? The issue tracking this seems to be marked as done, but I can't find it anywhere.
Can this issue be closed? Relational queries are a thing now.