For one of the projects I was working on at Karta, we needed the ability to search through songs. Specifically, players should be able to search for a song by name, tags, most liked, creator, etc. Songs should be sorted by newest to oldest as well. After much consideration and planning, I decided that the best approach would be to implement an external solution to the problem. Largely due to Roblox’s limitations surrounding DataStores. I chose Firebase as my service of choice, due to its simplicity and quick-to-start nature. I wasn’t looking for a complicated powerful beast like PostgreSQL which would’ve required a lot of maintaining, although Supabase did catch my eye.
After writing the database cloud functions in TypeScript (rusty as I am with JS), I needed to implement a Roblox-side backend API to interface with the database cloud functions and also to provide some level of caching. That is where the SongSearchService comes in! See: https://gist.github.com/RoyallyFlushed/a12bdd16223c6b04086366e9d6806d80
My goal here was to create a set of simple-to-use, but effective API methods which my team could utilise in order to interface with the database, and query it as seamlessly as possible. You’ll notice with respect to the Query method, that I have also implemented a SongPages data structure. I wanted to re-create a Pages object, just like Roblox use for their DataStore queries with the idea that it’d be extremely easy to understand for a native developer, while also hiding the pagination cursor logic required to query the next page of data.
