mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
feat: Add saveDraftChanges API endpoint to update product drafts and correctly set codeGammeInit using COALESCE.
This commit is contained in:
1 parent
54a4e7f4d1
commit
6529b2fe15
2 files changed
+21
-16
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
import { db } from "@/db";
|
||||
import { ventesProduits } from "@/db/schema";
|
||||
import { eq, and } from "drizzle-orm";
|
||||
import { eq, and, sql } from "drizzle-orm";
|
||||
import { z } from "zod";
|
||||
|
||||
import { revalidatePath } from "next/cache";
|
||||
@@ -39,7 +39,10 @@ export async function saveDraftChanges(
|
||||
|
||||
return db
|
||||
.update(ventesProduits)
|
||||
.set({ codeGamme })
|
||||
.set({
|
||||
codeGamme,
|
||||
codeGammeInit: sql`COALESCE(ventes_produits.code_gamme_init, ventes_produits.code_gamme)`
|
||||
})
|
||||
.where(and(...whereClause));
|
||||
})
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user