0

This should be pretty simple, according to the docs...I'm trying to store and retrieve a string in an encrypted column in my Supabase database.

Inserting a string manually via the dashboard works - the string is encrypted and then I can view it in the decrypted database view. But if I insert a string via the API, then the decrypted value isn't displayed in the decrypted database view or formatted correctly when it's retrieved via the API. I still get an encrypted string back.

api_key is the encrypted column.

async function saveCustomer(customerId, accessToken) {
  const customerData = {
    id: customerId,
    api_key: accessToken,
  };

  try {
    await createRowInTable('customers', customerData, 'id');
  } catch (error) {
    throw new Error('Unexpected error in saveCustomer:', error);
  }
}
async function createRowInTable(tableName, rowData, conflictField) {
  try {
    const { data: result, error } = await supabase
      .from(tableName)
      .upsert(rowData, { onConflict: conflictField });

    if (error) {
      throw new Error(`Error inserting row into ${tableName}:`, error);
    }

    return result;
  } catch (err) {
    throw new Error('Unexpected error in createRowInTable:', err);
  }
}

Note - I've asked about this in the Supabase Discord and created a Github Issue but got no response after more than 12 hours. I'll update this post if I find the solution elsewhere first.

Alex S
  • 190
  • 3
  • 15
  • We finally have some progress on this in the [GitHub issue](https://github.com/supabase/supabase-js/issues/795). – Alex S Jul 08 '23 at 07:33

0 Answers0