© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago•
1 reply
nomz eater

extract table names from db.query

Hi all, I want to extract the name of a table like this

this.db.query
this.db.query


however if I were to do this

type model = typeof this.db.query
type model = typeof this.db.query


it gives me a readonly version of what I really want, and because my goal is to do something like this

  async findById(id: Id) {
    return await this.db.query[<dynamic key>].findFirst({});
  }
  async findById(id: Id) {
    return await this.db.query[<dynamic key>].findFirst({});
  }


however this is unsuccessful because the when I try to use the
type Model
type Model
from above it gets angry because
this.db.query[model].findFirst
this.db.query[model].findFirst
gives me the readonly value, but I want a non readonly value so I can use it properly. Any help is appreciated
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Extract a type from a table
Drizzle TeamDTDrizzle Team / help
3y ago
Extract interface for table from schema
Drizzle TeamDTDrizzle Team / help
3y ago
Dynamic Table Names
Drizzle TeamDTDrizzle Team / help
12mo ago
How to query join table with db.query syntax?
Drizzle TeamDTDrizzle Team / help
15mo ago