[New Plugin] Supabase.js - With Auth, Data and Storage

Hi there, can you guide us about this one? Might be useful in one of my projects. :slight_smile:

Also waiting for this one. This will be very helpful. Being able to return the values you recently created in a wotkflow. Like referencing workflow result in a bubble way such as “step 1’s result : id”

Another question, is there any “Upsert” action? I can only see Insert and Update but not upsert.

Also how can I add bulk data?

Use case;

I have a join table for Subjects and Students. I want to be able to join student “Tom” with subjects “English” “Math” “Science”. (Subjects already exist in database)

Is this the correct workflow?

  • Create a row for Student “Tom”
  • create a row for each of joins
    — Create row for subject _student joins “Tom” : “English”
    — Create row for subject _student joins “Tom” : “Math”
    — Create row for subject _student joins “Tom” : “Science”

Is there an action that can simplify the join tables? And make it dynamic?

I’ve added this small guide for foreign table query, might add later some more advanced things.

This I’m working on although I cannot return it inside the action, only with the API connector you can do. But it will be saved inside the element in a way. Upsert and bulk data is also on my list, with Bulk data as higher prio, so I’ll try to include that in the next updates.

Thanks for this. This is helpful.

So we need to reinitialize the call with the foreign table right?

How can we add rows for join tables then? What will be the ideal workflow using this plugin? Let’s say we want to add a new post the. Add connection with that post to different categories. What will be the ideal workflow in bubble?

This is really comes down your Database design, and also how you return the data to Bubble, so what is available. In my app I usually try to minimize join tables, and I return data I need on page load, so when I create new things, I can cross-reference the Outputs of several Supabase Data Elements.

In the Meantime I’ve also pushed a new version including:

  • Bulk Insert for Data
  • Deleting User action (This require the Service Key in the Plugin settings)
  • The Data element will automatically rerun the query when input changes, this is mostly useful for pagination. This also makes the “Refresh Data” action deprecated, which will be removed after 2.0.
2 Likes

How would you create many to many relationship without join tables? I want to minimize join tables as well as I’m not that familiar with SQL, coming from bubble.

Thanks for the bulk insert, will check this later.

1 Like

Thanks for the bulk insert for Data. :smiley: I already checked it. I think the missing item is the return value of newly created rows. Hopefully, we can create something like the “Result of Workflow 1”.

Some more new updates for [1.8.0]

  • Phone Auth now supported for the Auth element. There’s a new state for Phone Number, and two new actions: ‘Create a Mobile OTP’ for creating a One Time Password and sending it to their phone, and also ‘Verify and log in through OTP’ to Verify the Token and login when successful. Make sure you setup Twillio or other providers correctly first.
  • The ‘Create a new Thing’ action returns the newly created thing to a new state ‘New Thing’ so you can reference in workflows or on the page. This returns the single entry as opposed to a list.
  • Some more code optimization so Auth Initialization is now even faster on page load.
3 Likes

I don’t use Supabase, but this looks like a super cool plugin seeing all the updates.

I bet you are absolutely dying to be able to return values from the client side actions :joy:

2 Likes

It’s literally all I wish for :smiley: (Please Bubble make it happen :pray:)

1 Like

Wow. Thank you for the update. This returns the value of single row only right? It does not work with the bulk create data right?

Thank you so much for this. Will try this tomorrow. :slight_smile:

Hi @petersas
Great plugin and a great service to the community.

I have a query about returning a linked field’s data. I.e I have a table of metric and a table of metricgroupings with a field in the metric table called ‘Grouping’ which is referencing the metricgroupings table.

In the API call for getting metric and metric groupings. When I set up the metric call I link it to the data type created when I set up the metricgroupings call

In a table I have the field set up as so

I want it to show the Grouping field because of the relationship I have set up, but it’s just showing a blank. It’s not to do with RLS. Am I missing something obvious?

I can get it to work by setting up another API call which has a filter for the Grouping ID field

and then putting this call in the table where it returns the value where the rows group ID is used to return the grouping name from the API call

I’m just checking how you do it with your data and ensuring I’m doing it efficiently.

Thanks
James

1 Like

Hi James!

If you’re trying to cross-reference the values in the API connector, I don’t think that’ll work like that.
All you have to do is initialize the API call with the Foreign Tables and you only need to set the type of data it’s expected to be returned. So in this case MetricGrouping is a number. If you’re using the plugin or the API connector you should be able to also use eq to filter foreign tables.

Thanks, but I’m still not clear on what is possible client side with the plugin.
Can a table or repeating group have its data source set as one thing, let’s say cities. You have a row with two columns, City and Country. Can the country name be pulled through from the country table into that ‘City’ repeating group? An example would be great :slight_smile: The foreign post on your demo page doesn’t have mixed tables within the same repeating group, only seems to use a foreign table as a filter option. Help appreciated - I’ve spent a few hours on this!

I can do it via an API call, but obviously trying to use client data element to reduce WU.

Hi @petersas I didn’t found any example in your demo of how can upload files, and how can get the url when upload a file?
Thanks in advance

I show the name from a foreign table, so “category_ft” column name is a table called “Category” and inside the Repeating group I show the name of that, of course it will match to the value in the dropdown. With your example the API call would look like this: yoursubapasebaseurl/rest/v1/City?select=*,Country(name) or using an asterisk to return all columns for Country. With the plugin the value of the select parameter would go to the Columns field.

It’s a regular file uploader based on Better Uploader, so essentially you have an event called “SupabaseStorage A has_a_file(s)” and an action “Upload File SupabaseStorage A”. You can use the also the success and error event to track. As for the url the element don’t return it yet, but essentially it’s an S3 compatible API, meaning your url will always have the same structure: https://*yoursupabaseurl*/storage/v1/object/public/*nameofyourbucket*/*filekey*

1 Like

Peter, have been camping for the weekend and only just had a chance to try it out. Thank you so much. It works perfectly now.

And for anyone else who comes across this, you can do multiple linked columns in the same repeating group with additional supabase tables in the url

…supabase.co/rest/v1/MainTable?select=*,ForeignTable1(Columnname,AnotherColumn),ForeignTable2(ColumnName)

And in the supabase data element, ensure you have this part of the url if you want all the columns from the ‘maintable’ and the columns identified from the foreign ones

*,ForeignTable1(Columnname,AnotherColumn),ForeignTable2(ColumnName) in the ‘Columns’ field

image

2 Likes

@petersas can you add multiple filters on the Delete a Thing action? Maybe up to 3 filters?

I’ve added a new update for the Delete Action to use the an Advanced Filter just like for the initial query.
I’ve also pushed some fixes for the empty value bug, however it’s still in progress just because how the API connector is built, and it can be super tricky. So I’d recommend just having a default value of “[]” for lists that should fix the issue.

1 Like