© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
23 replies
MaxTechnics

Upsert with 2 conditions

I have a tool that keeps stats, every day for an organisation it keeps a set of data. However using the following query, it overwrites the row, even when the date changes:
const { error } = await db.from('absence_analytics').upsert({
        org_id: org_id,
        absence_count: finalized_crawl.meta.absence_count,
        unique_absences: finalized_crawl.meta.unique_absences,
        crawl_timestamp: finalized_crawl.meta.crawl_timestamp,
        date: date,
        period_1: finalized_crawl.data.period_1 as unknown as Json[]
///.. more rows
    });
const { error } = await db.from('absence_analytics').upsert({
        org_id: org_id,
        absence_count: finalized_crawl.meta.absence_count,
        unique_absences: finalized_crawl.meta.unique_absences,
        crawl_timestamp: finalized_crawl.meta.crawl_timestamp,
        date: date,
        period_1: finalized_crawl.data.period_1 as unknown as Json[]
///.. more rows
    });
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Upsert stuck
SupabaseSSupabase / help-and-questions
13mo ago
Upsert onConflict
SupabaseSSupabase / help-and-questions
4y ago
Upsert a specific row with API
SupabaseSSupabase / help-and-questions
4y ago
Use upsert(dataset) or insert(dataset, {upsert true})
SupabaseSSupabase / help-and-questions
4y ago