CMarker
CMarker
DTDrizzle Team
Created by lasse on 10/9/2024 in #help
Trying to use deno...
have you tested on explicitly providing a path to the drizzle.config.ts using the --config flag?
6 replies
DTDrizzle Team
Created by lasse on 10/9/2024 in #help
Trying to use deno...
Not an expert on Deno, but... Do you have a drizzle.config.ts file at /Users/lasse/Documents/dev/discordtempdenodrizzle/drizzle.config.ts ? 🥲
6 replies
DTDrizzle Team
Created by CMarker on 9/9/2024 in #help
Subquery in select, and referencing value from outer query
Hi. Yes i found out yesterday that that was the case.
5 replies
DTDrizzle Team
Created by CMarker on 9/9/2024 in #help
Subquery in select, and referencing value from outer query
I've tried this: but i'm getting the error error: invalid reference to FROM-clause entry for table "subscription_monthly_usage"
const callsSecondsSubQuery = this.db
.select({
id: subscriptionUsageCallsStarted.subscriptionMonthlyUsageId,
callSeconds: sum(subscriptionUsageCallsStarted.duration).as('callSeconds'),
})
.from(subscriptionUsageCallsStarted)
.where(eq(subscriptionUsageCallsStarted.subscriptionMonthlyUsageId, this.table.subscriptionMonthlyUsageId))
.as('callSeconds');

const result = await this.db
.select({
year: this.table.year,
month: this.table.month,
subscriptionMonthlyUsageId: this.table.subscriptionMonthlyUsageId,
callSeconds: callsSecondsSubQuery.callSeconds,
})
.from(this.table)
.leftJoin(callsSecondsSubQuery, eq(callsSecondsSubQuery.id, this.table.subscriptionMonthlyUsageId))
const callsSecondsSubQuery = this.db
.select({
id: subscriptionUsageCallsStarted.subscriptionMonthlyUsageId,
callSeconds: sum(subscriptionUsageCallsStarted.duration).as('callSeconds'),
})
.from(subscriptionUsageCallsStarted)
.where(eq(subscriptionUsageCallsStarted.subscriptionMonthlyUsageId, this.table.subscriptionMonthlyUsageId))
.as('callSeconds');

const result = await this.db
.select({
year: this.table.year,
month: this.table.month,
subscriptionMonthlyUsageId: this.table.subscriptionMonthlyUsageId,
callSeconds: callsSecondsSubQuery.callSeconds,
})
.from(this.table)
.leftJoin(callsSecondsSubQuery, eq(callsSecondsSubQuery.id, this.table.subscriptionMonthlyUsageId))
5 replies