CMarker
CMarker
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 11/16/2024 in #help
Brand ids?
Just tested this raw SQL query. SELECT 'users_' || users.id AS id FROM users and it gave me the concatinated string in return
9 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 11/16/2024 in #help
Brand ids?
note the removal of .transform() on the ID property on the table defenition.
9 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 11/16/2024 in #help
Brand ids?
I have never tried the Query API, and are not familiar with this. Can you try this? edit... i just testet to add mapWith to a uuid in one of my applications. And it looks like this function is only defined on aggregate-functions like sum, avg etc.. not the uuid type. So i guess that what you are trying to do is not possible with drizzle, and should be done using typescript casting or mapping over the result and concatinating the id column. export const usersTable = pgTable("users", { id: uuid().primaryKey(), createdAt: timestamp().notNull().defaultNow(), givenName: varchar({ length: 64 }).notNull(), familyName: varchar({ length: 64 }).notNull(), }) const result = await db.select({ id: usersTable.id.mapWith((value) => UserId(value)), }).from(usersTable);
9 replies
DTDrizzle Team
Created by Gary, el Pingüino Artefacto on 11/16/2024 in #help
Brand ids?
I guess you can use the .mapWith((value) => {...}) function. Regular: .mapWith((value) => UserId(value)) Curried: .mapWith(UserId)
9 replies
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?
7 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 ? 🥲
7 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