How do I reference data from a Supase Select in a workflow

Hi,

Am trying to get the hang of Supabase. From what I can gather I can either use Data Collections or a Select function in a workflow.

What I don’t understand is how to reference the data that is retrieved from the Select in the workflow to bind to variables.

Thanks
Steve

Hey Steve,

You can get the data from the workflow actions here:
To actually see any data, you need to run the SELECT by clicking test.

Got it - thanks!!

Hi,

I am trying to access the data to display on a page but notice that when the workflow option does not show up when trying to bind data on the page.

Is there any way to make this workflow data available outside of the workflow other than assigning it to a set of variables?

Thanks

This might be a case for using component. Depends on what you’re showing.

But no, if its not saved anywhere, you can’t access it. The case for a component is that the component itself loads the data, and the component is the only thing using the data. (Saved to a component variable)

Maybe you’re looking to use a collection instead?

Hi,

Yes, I believe that the collection is the correct way to go but I cannot figure out how to retrieve only 1 record. I asked this in another thread but haven’t has any responses as yet.

I am trying to get the last inserted record and don’t want to pull all the data and then to filter in the front end for performance and security purposes.

Do you know how this can be done?

Steve

Sure, there’s a couple of ways to goal here, depending on how your pages are set up and when you’re getting this information. Here are some suggestions.

Let’s say, you have create a thing then navigate to thing details.

  • You can add a collection called current_thing filtered by id = 123. id is defined by for example query param. ie. .com/details?id=123.

  • Or you can have a component that SELECT and stores the data in its own variable. You would run this component action on page load, or on mount, or whenever it suits you.

Or.. Let’s say you have a list of things, then you want to **create a new thing and add it to the list.
**
You have a collection called things, and a action that insert a thing into database. You can check the toggle to “return inserted row", then in the workflow Update collection to add the newly inserted data to the collection (without calling backend one more time).

I don’t know exactly what you’re trying to achieve but I hope some of these methods give you some pointers!

Thanks for the suggestions.

I am gathering information on Page 1, storing to a table on Submit and navigating to page 2. Once on page 2, I want to display some of the information including a row id that would have been created on saving to the table.

What I wanted to do with the collection was to retrieve a single record sorted by created_at desc.

Based on your suggestion, I used the Return Inserted Row option and that worked.

Thanks again

Steve