Supabase not updating columns using upsert

143 Views Asked by At

Whenever a user clicks on the same item again I want to update my "quantity" and "price" but not the "item". I tried using upsert, its successful but its not updating when i click on the same item again any solution to this

const incrementOrder = async ({ item, quantity, price }) => {
    setOrderCount(orderCount+1)
    const { data, error } = await supabase
      .from("ordereditems")
      .upsert(
        [{ item, quantity, price }],
        { onConflict: ["item"], ignoreDuplicates: true, set: { quantity: 'quantity + 1', price: 'price + excluded.price' } }
      );
  
    // Handle error or use the data as needed
    if (error) {
      console.error("Error during upsert:", error);
    } else {
      console.log("Upsert successful:", data);
    }
  };
0

There are 0 best solutions below