Using onConflict for date?

Hi all, I am trying to update the entry for a date if no entry exists on that date, otherwise insert a new entry.

Is upsert the correct was to go about this with onConflict and ignoreDuplicates?

I get a 400 bad request with the following:

const { data, error } = await supabase
      .from('daily_metrics')
      .upsert({
        user_id: userId,
        created_at: today.replaceAll('/', '-'),
        weight: dailyLog.dailyWeight,
        morning_systolic_pressure: dailyLog.morningSys,
        morning_diastolic_pressure: dailyLog.morningDia,
        strength_training_duration: dailyLog.strength,
        cardio_training_duration: dailyLog.cardio,
      },
      { onConflict: 'created_at', ignoreDuplicates: true }
      )
      .select()


Any direction is appreciated.
Was this page helpful?