machour
machour
DTDrizzle Team
Created by machour on 5/17/2023 in #help
Proper query results inference
Posting my GitHub discussion here for more visibility: https://github.com/drizzle-team/drizzle-orm/discussions/583
8 replies
DTDrizzle Team
Created by machour on 5/7/2023 in #help
Is there a way to modify the select() on an existing query ?
Let's say I have this query that I pass to a function
const query = db.select().from(myTable)
const query = db.select().from(myTable)
in my function, I'd like to clone the query, and modify its select() clause to something like this:
.select({
totalCount: sql<number>`COUNT(*)`,
})
.select({
totalCount: sql<number>`COUNT(*)`,
})
Is this possible? My current workaround is to inspect the config property on my query to create a new one, but I know that I shouldn't mess with internals:
db.select({
totalCount: sql<number>`COUNT(*)`,
})
// @ts-ignore since config is protected
.from(query.config.table)
db.select({
totalCount: sql<number>`COUNT(*)`,
})
// @ts-ignore since config is protected
.from(query.config.table)
9 replies