How to check if a Row exist in Supabase?

Hi @YogiYang, welcome to the community!

I think the cleanest way would be to use the PostgreSQL node. Supabase allows direct connections to the PostgreSQL database, with the credentials being available under Project Settings → Database.

Assuming my Supabase table looks like this:

And my n8n data looks like so:

image

I could then run a simple SQL query telling me if a row exists or not, for example like so:

In a workflow this approach would look like so, I’ve also added an IF node to process the result of the SQL query:

Hope this helps!

Btw, this isn’t the only option, just how I’d personally approach such a workflow for best readability. Instead of the query above and depending on how your table is set up you could for example write an UPSERT query (and wouldn’t have to implement the IF part of the example above).

You could also use the Supabase node with the Row → Get Many operation to see if there’s a match for your existing data. You would need to break down your data into batches of 1 in this case though, and build a looping logic similar to what I did here for Google Contacts.

2 Likes