Chris D.
ย ยทย Eternally curious

Supabase Multitenancy

Database & APIs

We are building an app for e-commerce merchants, their consumers, products, orders, and more. A highly relational structure. We opted for Supabase for Authentication and the database to service the application.

An authenticated User can take actions on products in our dashboard to create settings for campaigns. When I put together the backend query on Supabase -> Products and go to constrain that data using the filter, I am assuming I just need that the user is Authenticated and the multitenancy restricts the products the user can see.

Our hierarchy looks like this: user is FK on a store, store is an FK on a product so by filtering on the Auth User I believe we are only getting the products for the store the user is a FK on.

The Auth User is also not stored in the Supabase db we import. There is a second USER table that connects to their auth data and allows them to manage their profile and account.

I believe no filter is needed as long as the user is Authenticated, the only data they should see is where their authenticated userID is the userID on the store and or products.

What have you tried so far?

The database in Supabase is already structured for multitenancy.

A user creates a store, the store has products that belong to it, consumers belong to stores when they purchase and all of that structure is in place.

There is NOT a user ID on every table e.g. a userID on products because products belong to stores.

In the image below, the Authenticated User does not have an option to show the store they are connected to. But the Authenticated userID exists in another users table that is associated with a store and its products.

Did you check FlutterFlow's Documentation for this topic?
No
1