Supabase-luau v1.1.0-rc.1 | Enhancing LUAU with Supabase (PostgreSQL) DON'T USE YET

:warning: THIS IS AN ALPHA, MAYBE I WILL NOT UPDATE IT ANYMORE :warning:


supabase-luau

I present to you one of my best projects in LUAU: supabase-luau.

What is supabase-luau?

supabase-luau is a ModuleScript that allows you to manage relational databases with Supabase.

Supabase is an open source platform that offers an alternative to cloud database services. It is based on the power and security of the PostgreSQL database management system, which is used by large companies and organizations worldwide.

What benefits does supabase-luau give you?

One of the best benefits that supabase-luau gives you, is the relational database management in Roblox, you also have the following benefits:

  • Graphical interface to visualize your records
  • Simple syntax
  • Ease of creating more powerful and secure databases
  • Being able to manage your records manually through a graphical interface
  • Ease of use
  • You don’t need to know much SQL to be able to use it.

Is there any requirement or knowledge needed?

You will only need to know: how to use the Supabase page, how to get the API key and the project URL.


Tutorial about CRUD with supabase-luau

I’ll leave you some example scripts using supabase-luau so that you know if it’s to your liking and so that you know how to use it without having to see so much documentation.

Creating a client with supabase-luau

local Supabase = require(<supabase-path>)

local client = Supabase.createClient({
    url = "url-of-your-project-in-supabase",
    apiKey = "your-api-key"
})

Read data from database

local data = client
    :from("my-table")
    :select("*")
    :execute()

print(data)

Insert data into database

local newDataCreated = client
    :from("my-table")
    :insert({ name = "isaac010901", gems = 0, money = 0 })

print(newCreatedData) -- { name = "isaac010901", gems = 0, money = 0 }

Update a data in the database

local dataUpdated = client
    :from("my-table")
    :update("name", "isaac010901", { gems = 10, money = 10 })

print(dataUpdated) -- { name = "isaac010901", gems = 10, money = 10 }

Delete a piece of data in the database

local dataUpdated = client
    :from("my-table")
    :delete("nombre", "isaac010901")

print(dataUpdated) -- { name = "isaac010901", gems = 10, money = 10 }
-- if we get all the elements from the database again, this record will no longer be output.

Modifiers and filters

Currently there are only these modifiers and filters:

  • order(column: string, asc: boolean)
  • eq(column: string, value: any)
  • neq(column: string, value: any)
  • limit(amount: number)

A modifier is a method that modifies how the elements are returned from the database, for example order() modifies the order in which the elements are returned.

These modifiers and filters are only useful when using the :select() method.

Example:

local data = client
    :from("my-table")
    :neq("name", "isaac010901")
    :order("id", false)
    :limit(5)
    :execute()

print(data) --[[[
    {
        [1] = { id = 5, name = ..., ...}
        [2] = { id = 4, name = ..., ...}
        ...
        [5] = { id = 1, name = ..., ...}  
    }
]]

It is important to know that supabase-luau is not perfect, and it is possible that there are things that can be improved or annoying to use, but it is still in its earliest version, I will give all my effort and knowledge in making this module the easiest to use and the most useful for you :metal:.

I would appreciate if you could comment and like my post, because I believe and feel that it can become popular and useful for the whole community :heart:

Test supabase-luau v1.1.0-rc.1


IT IS IMPORTANT TO KNOW THAT THIS PROJECT IS STILL UNDER DEVELOPMENT AND IT IS NOT RECOMMENDED TO USE IT FOR PRODUCTION.


Version table

v1.0.0-dev.1
  • Topic in the Devforum created
  • Repository has been created on GitHub
v1.1.0-rc.1
  • Documentation has been completed
  • supabase-luau is now downloadable for Roblox Studio (.rbxm)

made by @isaac010901

22 Likes

This is super cool! I’ll test it.

1 Like

Thank you very much! I still have to finish a lot and finish the documentation, the repository, the script itself and make it much better, I hope you understand that it is still in its development phase, but thank you very much and I hope it will be helpful when it is ready for production!

1 Like

Well, supabase is underrated so i think this module should be the new robase module for these things. You have all my support on this.

1 Like

Thank you very much! I will try to give my best to the community and try to provide everyone with a new and effective way for data persistence :slight_smile:

1 Like

thank god you made this aha, i was originally working on one for my own but this has saved me so much time

2 Likes

Since I see that more and more people are seeing this post, I am going to start improving the module, as soon as I have the documentation done and all the rest, I will mention you again, since it is not currently in production :happy2:

The documentation has been finished, you can now download it from the repository releases :slight_smile:

2 Likes

The documentation has been finished, you can now download it from the repository releases, you can now test it correctly, you just need to finish the tutorial but you can guide yourself a little bit by yourself :slight_smile:

2 Likes

thank you, i was confused on where the documenation was, i had toread through the module scripts to learn aha

1 Like

can you do rpc with this? cause im trying to help out my friend with using this

1 Like

I don’t know what you mean by “RPC”, I have no knowledge about this kind of things, but if you mean Remote Procedure Call, I BELIEVE it could be possible, I haven’t tried it, if you can give me more details about ut question I would appreciate it, I didn’t understand it very well :thinking:

i mean this Supabase Javascript Client - Call a Postgres function

calling functions on supabase

Oooh, PostgreSQL functions. It’s not yet possible to make these calls, in the future when I work more on this module I will be able to make this kind of calls and be able to use the other features that Supabase provides :smiling_face:

If I implement this API I will let you know! But the Supabase API documentation is very bad and it is complex to know how and where to do this :sad:

do you know how to insert jsonb?

1 Like

I’m interested in this, I currently use Firebase for all of my external database, so this would be a big upgrade to it. I do have some concerns:

  1. Whenever I update a key, do I have to do every single value, for this example, let’s say I’m saying gems and money, if I want to set only gems;
local dataUpdated = client
    :from("my-table")
    :update("name", "isaac010901", { gems = 10})
  1. What if I want to access the client in another script? What’s the recommended approach? I’m thinking to have like a supabase handler or something;
1 Like

you should use RemoteEvents for that, it’s not such a good idea but if you want to do it, you should make security checks

No, you don’t have to, you can do :update("name", "isaac010901", { gems = 10}) without problems!

Hi guys, thanks to everyone who liked this post, but I may not update this post or the module script anymore. Maybe if I get time I will, but I see it unlikely, I will keep you updated :pray:

This is great, and a stable production release would be amazing!
However, it truly is a shame that some sort of SQL Service isn’t implemented in Roblox directly and stuff like this is needed in place of it.

Thank you so much for reviving my post, I thought it had already died. I will try to bring out a stable version for the community, but these days I haven’t had time at all, anything I will let you know :happy1:

2 Likes