Cyber Grandma
Cyber Grandma
Explore posts from servers
DTDrizzle Team
Created by Cyber Grandma on 11/5/2024 in #help
Filter based on join data
Hi, would it be possible to query a list of student and filter by the name of its coach. The data is <student>.coach.fullname where coach is added as a with join. I would like to get every student that have a certain coach.
13 replies
DTDrizzle Team
Created by Cyber Grandma on 9/26/2024 in #help
Possible to have multiple onConflict ?
Hi, Would it be possible to have multiple onConflictUpdate statements ? For exemple "if conflict on ID do that" and "if conflict on clientId do that instead" ?
6 replies
DTDrizzle Team
Created by Cyber Grandma on 1/22/2024 in #help
Drizzle-kit not detecting views ?
Hi, I've created a view in the same file as my regular table:
export const userLevelsWithRank = pgView('user_levels_with_rank').as(
(qb) =>
qb
.select({
rank: sql<number>`rank() over (order by "level" desc, "xp" desc)`.as('rank')
})
.from(userLevels)
);
export const userLevelsWithRank = pgView('user_levels_with_rank').as(
(qb) =>
qb
.select({
rank: sql<number>`rank() over (order by "level" desc, "xp" desc)`.as('rank')
})
.from(userLevels)
);
But drizzle kit says that no changes were made.
No schema changes, nothing to migrate 😴
Did I miss something ?
14 replies
DTDrizzle Team
Created by Cyber Grandma on 11/21/2023 in #help
Insert or Update: Error undefined is not an object (evaluating 'col.name')
Hi, I'm trying to implement Insert or Update
export async function insertOrUpdateUser(user: UserInsert) {
const db = await getDatabase();

return await db
.insert(users)
.values(user)
.onConflictDoUpdate({
target: users.id,
set: user
});
}
export async function insertOrUpdateUser(user: UserInsert) {
const db = await getDatabase();

return await db
.insert(users)
.values(user)
.onConflictDoUpdate({
target: users.id,
set: user
});
}
I get this error:
TypeError: undefined is not an object (evaluating 'col.name')
at /app/node_modules/drizzle-orm/pg-core/dialect.js:74:41
at buildUpdateSet (/app/node_modules/drizzle-orm/pg-core/dialect.js:72:6)
at onConflictDoUpdate (/app/node_modules/drizzle-orm/pg-core/query-builders/insert.js:57:19)
at /app/src/db/schemas/users.ts:43:15
at processTicksAndRejections (:61:76)
TypeError: undefined is not an object (evaluating 'col.name')
at /app/node_modules/drizzle-orm/pg-core/dialect.js:74:41
at buildUpdateSet (/app/node_modules/drizzle-orm/pg-core/dialect.js:72:6)
at onConflictDoUpdate (/app/node_modules/drizzle-orm/pg-core/query-builders/insert.js:57:19)
at /app/src/db/schemas/users.ts:43:15
at processTicksAndRejections (:61:76)
Any idea what it means ?
23 replies
DTDrizzle Team
Created by Cyber Grandma on 11/9/2023 in #help
PostgresError: Relation X does not exist - After reorganizing schema
Hi guys, I have two tables (team and team_members) , which have a relation. All my schema was in one file and I decided to split it into multiple to make it cleaner. I ran the drizzle-kit generate:pg command with success, my app starts and does migration with success. But when I try to insert a new team_member it tells me that the relation does not exists. I find that odd, I also double checked I didn't delete anything. Any clue ? It's very late for me, perhaps i'm just missing something super obvious...
20 replies
DTDrizzle Team
Created by Cyber Grandma on 10/26/2023 in #help
Custom Logging: hide notice messages ?
Hi, I'm using Drizzle ORM with Postgres SQL. Every time I start my project, it does a migration and logs things like this in my console:
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P07',
message: 'relation "__drizzle_migrations" already exists, skipping',
file: 'parse_utilcmd.c',
line: '206',
routine: 'transformCreateStmt'
}
{
severity_local: 'NOTICE',
severity: 'NOTICE',
code: '42P07',
message: 'relation "__drizzle_migrations" already exists, skipping',
file: 'parse_utilcmd.c',
line: '206',
routine: 'transformCreateStmt'
}
I couldn't find a way to intercept these logs and handle them properly. Maybe it's not on Drizzle's side but on the Postgre Driver ? Thanks ❤️
3 replies