dsf_2
dsf_2
DTDrizzle Team
Created by dsf_2 on 7/31/2024 in #help
Updating multiple rows causes type error
It worked!! You are a legend thank you so much!
12 replies
DTDrizzle Team
Created by dsf_2 on 7/31/2024 in #help
Updating multiple rows causes type error
working on the raw, one min
12 replies
DTDrizzle Team
Created by dsf_2 on 7/31/2024 in #help
Updating multiple rows causes type error
It's the same as what is in the linked guide
12 replies
DTDrizzle Team
Created by dsf_2 on 7/31/2024 in #help
Updating multiple rows causes type error
This is the code
12 replies
DTDrizzle Team
Created by dsf_2 on 7/31/2024 in #help
Updating multiple rows causes type error
const sqlChunks: SQL[] = [];
const ids: number[] = [];

sqlChunks.push(sql`(case`);

for (const route of updateInfo) {
sqlChunks.push(sql`when ${routes.id} = ${route.id} then ${route.order}`);
ids.push(route.id);
}

sqlChunks.push(sql`end)`);

const finalSql: SQL = sql.join(sqlChunks, sql.raw(" "));

await db
.update(routes)
.set({ order: finalSql })
.where(inArray(routes.id, ids));
const sqlChunks: SQL[] = [];
const ids: number[] = [];

sqlChunks.push(sql`(case`);

for (const route of updateInfo) {
sqlChunks.push(sql`when ${routes.id} = ${route.id} then ${route.order}`);
ids.push(route.id);
}

sqlChunks.push(sql`end)`);

const finalSql: SQL = sql.join(sqlChunks, sql.raw(" "));

await db
.update(routes)
.set({ order: finalSql })
.where(inArray(routes.id, ids));
12 replies
DTDrizzle Team
Created by dsf_2 on 7/31/2024 in #help
Updating multiple rows causes type error
How do I get the raw SQL?
12 replies