I'm working with Supabase which has the ability to create database functions. In a table, I have a json column which holds an array of simple objects, that are tracking a user's onboarding completion.
The json array might look something like this:
[
{
"page": "dashboard",
"completion_date": "2022-07-18T17:10:42.254Z"
}
]
and so as you can see, it's only tracking two properties, page
and completion_date
. The issue I'm facing however, is that anytime a user goes to another page and completes the onboarding there, this value is being overwritten with the new values rather than inserted.
How do I go about inserting that new object if it doesn't exist, or updating that object based on the "page" key if it does already exist?