Implementing UPSERT/MERGE with Supabase

I have pretty simple need - I have a source in a file with ID and VALUE fields and I have a target Supabase table with ID and VALUE

I would like to update the VALUE field of existing records based on the ID field and insert new records for new IDs.

I’ve tried LOOPS… MERGE…

using n8n cloud

That feature is currently not available on the Supabase node.
But since Supabase uses Postgres, you can connect directly to the database using a Postgres node.

You are gonna have to create a Postgres credential to connect to your supabase database directly.

  1. To do that click the connect button on the top of your Supabase dashboard:
    image

  2. Scroll down to “Transaction pooler” and click “view parameters”

  3. Paste all that information into a new Postgres credential, in n8n

  4. To find your database password, go back to Supabase in Project Settings > Database


  5. Click “Reset Password” to be able to copy the password and paste that into the n8n credential.

  6. Create a new Postres node in your workflow and select the credential. Now you have the “Upsert” option for you database

.

:point_right: If my reply answers your question, please remember to mark it as a solution.

This is great - thanks!
But what I need to lookup in a separate data source?

I don’t understand your challenge.

In your first post you asked about how to update a record in the database based on its ID.

And if the ID doesn’t exist you create a new record.

What I showed you is exactly how to do that.

Sorry here is what I;m looking for:

Source 1 has ID and Value;

I want to lookup each record in Source 2 (any database) by ID and depending if it was found, update Source 3 or create a record in Source 3.

I see. What are the sources?

Each source will have a different way of searching them.
If they are also Supabase databases, you just need to create more credentials and use each credential in a separate node.