Lostra
Lostra
DTDrizzle Team
Created by Lostra on 3/13/2024 in #help
"onConflictDoUpdate" fails with error in Array.flatMap
This piece of code to update works (I know there's lots of duplicates)
protected async updateExisting(
data: typeof this.schema.$inferInsert | (typeof this.schema.$inferInsert)[],
): Promise<T[] | undefined> {
if (Array.isArray(data)) {
const returnArray: (typeof this.schema.$inferSelect)[] = [];
for (const dataEntry of data) {
const result = await this.repository
.update(this.schema)
.set(dataEntry)
.where(eq(this.schema.id, dataEntry.id))
.returning();
returnArray.push(result);
}

return returnArray as T[] | undefined;
}
// ... same for a single entry
}
protected async updateExisting(
data: typeof this.schema.$inferInsert | (typeof this.schema.$inferInsert)[],
): Promise<T[] | undefined> {
if (Array.isArray(data)) {
const returnArray: (typeof this.schema.$inferSelect)[] = [];
for (const dataEntry of data) {
const result = await this.repository
.update(this.schema)
.set(dataEntry)
.where(eq(this.schema.id, dataEntry.id))
.returning();
returnArray.push(result);
}

return returnArray as T[] | undefined;
}
// ... same for a single entry
}
The idea here is that it's taking a looooooong time to do a select for the ID, check if it's undefined or not then insert/update based on that.
4 replies
DTDrizzle Team
Created by Lostra on 3/13/2024 in #help
"onConflictDoUpdate" fails with error in Array.flatMap
Update: A simple update function fails with the same
4 replies
DTDrizzle Team
Created by Lostra on 2/27/2024 in #help
Insert silently fails with missing table name?
I used the getSQL() function on the whole insert thing, and logged it. At the start I can see the insert into section, and below that all of the table's columns (so it's picking up the schema) but in the rest of the object, there's not a single instance of accounts anywhere to be seen, and around the bottom I have a value: { " " } right before the actual insert values for the columns.
2 replies