- Podcasts
- CodingCat.dev Podcast
- Code with CodingCat.dev: Building your Own SaaS
Code with CodingCat.dev: Building your Own SaaS
CodingCat.dev Podcast
- June 30, 2024
- 1 h 31 min
- Season 1, episode 4
About this episodehttps://codingcat.dev/podcast/cwcc-2023-12-20-building-your-own-sass
Transcript
From the publisherThis transcript comes from the podcast’s own feed, shown as the publisher wrote it.
Code with CodingCat.dev: Building your Own SaaS
This episode of Code with Coding Cat is brought to you by our good friends at Algolia. Check out their search today. Algolia helps you create a search and discovery engine in three steps. Step one, import your data, import the API client, initialize the client and index, load the local Jason file and then push to Algolia.
Step 2. Configure relevance, define searchable attributes, add business metric, specify facets and filtering. And Step 3. Build your search UI, import widgets from the library, add instant search component, add search input refined by attribute, display results, add pagination and just like that you're done. Build search effortlessly with Algolia. Welcome back beeps to code with Coding Cats today on the show at Tim Medics.
What's up, Tim? Hello, that was one fancy intro for Algolia, and we're going to do exactly that today, which is cool. That is really cool. I I'm super, super stoked the folks over at El Golio are able to sponsor this episode, so shout out to them. If I remember and do a good job, I will occasionally show sponsored by El Golia. There we go.
So fun. So yeah, today we're going to do some coding with Super Bass Knox Del Golia. So try to kind of do a little bit upfront and then break into the coding for the last, I keep saying 60 minutes, but we tend to start early and do 80 minutes. So yeah, exactly. We're gonna, we're gonna definitely see how far we get. But first, the important part for me is how are you, Tim? I am great.
So I think it's already dark here though. You. You. Switch scrolls, right? Like you. You're at a different company now. I think I am Fancy Hatta, yeah. Yeah, exactly. I basically just did a hat change and I was just wearing the the hoodie from the other company. So I just took it off because that was a bit weird now like the last time I was here, I was still like uniform and now it's probably been a year already that I was on this stream.
And now I'm at Highgraph, which is a hatless CMS that's native with graph QL. And we have a whole bunch of like extra fun bits with like content federation. So you can add natively other AP is into the system and then content that us can use them without understanding those things. And like a lot of fun stuff as Acms plus an extra few fancy features for if you need to scale things like that. And so yeah, I'm really excited to be there. It's quite different, but you know, change is the spice of life, I guess.
So there we go. For sure. And so I know like we talked during COVID times and you kind of went from do I call you a Parisian? Is that correct? You could have because I lived there like 910 years but now I'm so different. Like I I live in the southwest of France now in complete nature. Like right now it just turned dark in the time we prepared for this dream.
But before I could see the forest in the hills and like there's no paved Rd. close to my house like it's that far off. So I'm ready to wear dickies and be slightly more farmer than Parisian. I would not work there anymore now. So it's quite different but I'm very happy here. Like it's super like lots of nature, fresh air, less stress. It's just lots of travel when I want to go anywhere. You just said Dickies and I was like, Dickies jeans, right? Remember that stuff?
So yes, we do. I don't my my wife would correct me 'cause I'm horrible about fashion and clothes and all that stuff. So like I either have jeans on or I have on like dress pants, which I would call, I don't know, maybe that this is this is going down. We're going fairly deep into, into a rabbit hole that's not building a sass, right? Actually, I, I really enjoy being on here with you as always.
And so this one is quite different than I expected initially because I'm literally a weekend warrior building a sass to solve a problem I see in our neighborhood. Because here in the in the countryside, there's lots of cats all around. They're just being dumped by people that didn't want them or they're born in farms.
They don't have, you know, all the health care that they need to become a happy, healthy cat without producing 20 other cats that are also unhealthy, essentially. And so you have a bunch of associations here around of people that just take care of these cats, you know, and they have all the deals with like a veterinarians to get free vaccinations and stuff like that or good prices.
But they have to somehow organize themselves. And that's where it turns really messy because what they have to do is have a database of these cats and then say you're the adoption family that fits this cat that has an amputated leg because your house is super clean or you are adoption family in town because this cat is super scared to be with other animals. So you have to be in an apartment. Like there's all these kind of things and it is a mess. Like looking at the Excel sheets that these people make. Holy moly.
Like us tech folks, we kind of structure these things. But for them, that structure their brains is very different, right? And but what they also want is like having a little website where they can present all the cats to, to, to say, Hey, do you want to adopt this cat and then post it to Facebook or who they have all, they have Facebook groups and stuff. And so I thought, why not make a little sauce where all these associations can just make a free account or they pay like 4 bucks a month, something like that where they can put all their cat data historically sorted and stuff. And then also make a little website and then get like people that might want to give some money or become a host family and then fill out a form with all the questions and say, Hey, I want to be this.
And so I'm weekend warrior and that's not a word. I'm working in the weekend to build this stuff and what other to use Super Bass Knucks and Algolia. That's like the such a good match. And So what do you want to do today, Alex? You like kind of quickly show it and then we go into how you would build something like that. I feel like which?
Hyphen. What do you think? I think that would be really cool because you're, I mean, I know you're not done with the product, but I think it's a really good, I think it's a really good lead in to at least show it. And we're going to take it almost from scratch, basically like a raw repo and like build out features so people can get used to doing it.
So yeah, please, please share your screen and. Let me just share my screen a little bit so you can see what we're dealing with here You have. I have to caveat this thing because I'm learning as I go. Oh, I like it. I mean I. That's part of the game, isn't it? Oh, totally. And I've, I've used Al Golia before. I haven't done much with Super Bass other than like log in and check it out, but I definitely don't know of you and so you're gonna have to help me out a lot when we go through. That is all good.
Yeah, either way. Anyways, so essentially what I've built is like this is Next UI running in next having had data from Superbase pushed into Algolia because the Super important thing is that this cat database, so this is like full of cats here. So I'm just going to this page here and this is still some fake data.
This is not exactly correct. But you can see for all these cats like birth date and then are they dead or not? Because that sadly happens quite a bit. You know, when they were arrived at the association protocol means there's like this whole health protocol. They all get all the time to just have them good as a, you know, base health. And then there's so much stuff here about like adoption, which families are they like because they also have temporary families sometimes.
And then collar, are they good with dogs and cats? And like you see, every time I hit a, a checkbox here, you can see it automatically saves this thing now in super base and so you can add images. This is really cool. So. Just a question on the UI. So Nuxt UI, is that something that Nuxt maintains themselves?
It's something called Nuxt Labs, which is a side gig of the next guys and that's actually where they make money. So they have next next UI pro and there's like next studio and there's a a project like Faulta. And so the next team maintains these things and so it's on the side and, and that they give you all these kind of like good things and all the buttons, all that stuff came from next UI. Like if I want to do a pop up like this or all that stuff comes from that and it works super well and it integrates very easily with a bunch of other things like this graph does not come from that GY, but you just put it in and then it kind of just adapts well.
And so there's all these kind of like little goodness things that I'm working on, right? When you add this in, there it is. And so it's all good fun. And so this part is just dealing with the cats essentially. And so where it gets interesting with Algolia is that now these folks can say, OK, I want the the family where they are AT and I want all the female cats. And so it filters down really quickly. And so they can actually make, and you can see the URL updates also.
And then here you can also choose, let me just add certain fields, yes or no. And all this comes from Next UI combined with Ligolia. And that's just, it's kind of magical, right? It works pretty well. And this is all like the fencing of Ligolia because when I type this, it filters, but when I actually add like my name, which is one of those families, it filters on that as well.
And so that's all set up in Ligolia and that works just so well. And just for the the viewers looking at like, hey, Tim, why is half of it English and half of it French? That's literally because I'm just whacking this stuff in there so my wife can say, oh, yeah, that works. Let's let's go with this.
That's cool, right? So there's no localization or anything in that just yet. It's just like this means like adoption family and this means host family, like stuff like that. I just had to put it in so she can see how it might look later. And so. With that in mind, we have foster family, so you can become a family and add a new family and you can be an adoption one or host or both because we need this information for people to be able to, you know, have a database of this stuff.
And then the last. You were like modeling out these databases where you're kind of just doing it all in your head, or did you lay it out and use a tool to like pull it into super basin somewhere? I tried to use a tool, but it didn't really work. So I would, I just spent way too much time in Superbase. But I'll show you in a SEC what it came out to be. And it actually works pretty well. And so currently I'm working on this bit because I want them to be able to build a site with this data in here and that just outputs to some static next site somewhere. And so right now it's still quite abstract. So I'm building pages and components. And so I just made like a hero component and each hero component has a field.
So this starts to look like a hatless CMS, which I didn't want, but it kind of needed like, so if I want to make like a text field, I can just add a text field and say this is title and then title, whatever, I'll put something in. And so now this has a bunch of fields. And when I go to pages, I can actually say, you know what, there's that hero component. Let me just add it in.
And so I'm currently like, now you have two, but it's this is all just Jason because I'm literally working on this today. So. And the ID will be that people can drag and drop and this will become what you see here, will become a form so they can actually type all the stuff. And then on the side, they'll see the updates in the website live. How does does the form get built out dynamically like SSR? That's wild.
So now I screwed something up. I think like you see nothing here now but like. I do. Exactly, I'm working on that stuff. And so to have a look quickly in Superbase, this is the data model. And I know I realized this is small. So in the end, the cat itself has a ton of fields, right? Whereas they like all dates, booleans, things like that. And then each cat has a host family ID and an adoption family ID potentially, which is then connected to a family's database.
And then there's also they need to get weigh insurance sometimes. And then it's, it's a date and a wait. And so they're connected to that because I need to be able to make that graph, right? It needs to be separate data entries. And then treatments as well, because there's a bunch of different treatments they can get.
So when you look at a treatment is like an innumerable type. So a bunch of things it can be. And we look at that. You see here, there's a bunch of different ones. First vaccination, second vaccination. Deworming or corona this? Is amazing because this is in Superbase itself, yes? That's why Superbase is so awesome. It allows you to just build this kind of in forms and stuff. That's really cool.
So you can look at the schema here and you say, OK, this is my cat schema. And so you can actually edit that table in here if you wanted to. You see, these are all my fields. I just put them in like this. Of course the real backup developers are going to more have a look at the definition like this and then run it like that.
But I'm that's not my Forte to be. I thought I was like super full stack. I'm not, let's be honest. It just, this just works well and they just give you so much lovely tooling to to like get stuff done. And it seems like it will scale really well too. Well, I've done one of my conference talks where people were life voting on stuff and every photo they did was like a new database row.
And then I had a watcher on the database row in real time and showed something on the screen and for 20 minutes, 1500 people were just like folding like that the whole time. It didn't even break a tiny sweat. It was. And were you hosted on their cloud at that point? It's all on on superbase.com free account. That's that's unbelievable.
Ridiculous. That was that. What that was view count for something? I did like that talk. I was playing guitar so people and that was like I did it like 7-8 Times Now and it was ridiculous how well the skills. But also everybody who voted, I like, I think like there was like 2000 people on the platform at the same time at certain events and cloud an area was on like in runtime, even making their profile images like circular and puts them on a canvas.
Like all of these tools scaled like nothing I've ever seen. And so I'm going to stick with this super based stuff because it scales like nothing else. And it's, it's so easy to use. I had to get used a lot to things like this though. And we might get into that when you start trying, there's like policies here, right? So in this case, I made a policy that authenticated users can actually create, remove, and update things, but people who are not authenticated can actually not even see these database rows.
And so these policies were kind of a little tricky to get started with because I wasn't used to that. Yeah. Yeah, but we'll get into that, I think. That's powerful. It is extremely powerful. I would. Imagine we'll have to be careful when we pipe over data into Algolia. Like what data and like sensitivity is going? 100% and so right now I chose because we haven't even shown Algolia just yet.
I should have actually probably just put the ID in there. But what I want to do in here, I go to my cats. I kind of just want to filter on this family and then go into that cat and do something about it. Yeah. So there's a give and take to be figured out. Luckily all the stuff you have to be logged in to be able to see, like if I log out now.
The only, the only tricky part there, Tim and we can, we can look at it, but like you have to set certain things up in Algolia so that when we're grabbing that data, we don't need it as well. So. Yeah, and everything now in here is all fake because I wanted to keep it fake for now so that that's all all right. Well, I'm, I'm stoked.
I mean, we're 20 minutes in. I think we did a good demo. We have a base now, right? Like this is a good base. Let's let's start cranking on code. And I know how slow I type, so I. Think me too, this took a while so I just killed my screen share and just go in it with you man. So for our audience, I've created like a base repository that has next next UI and also the packages for Super Bass and Algolia.
So. I think we'll, we'll probably be typing a lot, so I'll try to make this as big as possible for folks. Literally the only thing when we deliver this repo back to you, you'll probably see a lot of this done. And I'll hold that in Coding Cats GitHub. So when you load this up you should only have to do PMPM install to get that rolling.
I will move off this main branch right now and do a new one just called final or something like that. Yeah, because what we need is a super base account and an Algolia account, and we need to have the credentials set into our environment variables. Because without that, as you can see right now, it doesn't even run.
So let's get that stuff first. So if you're out in Elgalia, let me go home real quick. So this is kind of my main screen. You might get a pop up if you've never been in here, and it'll walk you through some more of this. But you should eventually be able to to get to the point where you can create a new app.
So I'm going to create an application. I'm gonna put it closer to me and that Tim. Sorry, Tim. Yeah, it's all good. It's faster for you and you're streaming. So Oh my goodness. Oh, it's not cats. Oh crap, yeah, I know. We've we've really broke our brand here. Yeah, actually it's so much fun that like we're I'm calling Catdev, building a cat database.
I know the Catnip DB by the way the. Crazy part is you were doing it before we even talked about doing this. Stream. It's organically fits, right? It's kind of nice. What do you think suggestion here? What are we looking at? I'm just. Sorry, index on the Algolia, let me let me make this larger so people can see that just having a.
But in reality, just think of this as like a storage area or a project at this. Point. Yeah, because they or you know why they call it an index. When you have Postgres DB like in Superbase, you create an index for certain fields you can search into, right? And now they call this an index. But this is literally just for searching, but it's a similar wording I guess.
Yeah, it's, it's interesting. So I've got all of that, I think. We don't have data just yet. Do we need data to do anything? Well, of course, because you need to be able to get some search data back, but we need to get that data first from Superbase. That's why I was wondering if we need an API key or just wait.
Get the API key so the app can at least run. So that's what I'm struggling with. Where do I head free? Yeah, you go to your your settings, yeah. And then there should be a drop down where you can select what you're. Yeah, I think that's probably the new one. And then here you should, oh, wait, go to the right top.
Try. Let's try and just type it all in and then we'll see where we get. Exactly, for now just do dot env and just get your normal key to search only. Oh, do we need? Yeah. Yeah, you need the application ID as well. Search only. Yeah, just go for this for now. Does that. Yeah, that's that one, yeah. OK, cool.
Oh, it might not. It might not let me. So password 1234. That's not going to get better. I know their CTO is not going to allow this for you. Man, all right, I'm just going to generate 1. Yeah, exactly. That sounds good. Let's see. WN, California? No thanks, that's too far away. It's too far away man, we need something in the middle. Perfect.
I know I need Iowa or like Ohio would even be better for me. All right, so we have 3. Your API keys right now, so we can already copy these. So this one. Yeah, I think that's enough for now. And then we need your URL which is a bit below. Yeah, this one. Sweet. OK. Right, so should we just try and run the app now? Now that it has all the data, let's see if it actually is. Happy doing PMPM dev, looks like we got some fun tail and stuff kicking through.
Yes. And that's what comes out-of-the-box essentially with a next UI that you stillwind. There we go and you see this login. That's what I made for you. So at least we're not, you know, we don't have to code the whole state of this form and then like confirms and all this stuff. Let's take a quick look at what login is though, of course. Yeah, so that's a page.
And So what is your, what are you most used to right now with your frameworks? It's probably spelt. Good right health or or next yes, I kind of go back and forth on either of those so. So with Nuxton Few, it's very templately driven, right? So you have your code bit on the top, and whatever happens in there is represented in the template below. So it's one file.
It's a bit like Svelt in that sense. I I feel like all these meta frameworks are getting pretty close. There's some syntax that's a little different, but true. Well, next GS, you can do Everything Everywhere, which is slightly different, but they're getting towards this even more nowadays to be fair.
And so in few, like all this U container, U card, all that stuff is essentially just next UI components that we're using here. And like this little template thing that you can see on like below you like that's the template of the full few file. When you go to line 43 there's another template and you can see that has hash header which is essentially like a little hook into the the the component that Next UI gave you to do anything custom you want.
Nice, cool. So I don't know how you call that like in in few and next you call this a slot. Yeah, slot. I think is. Makes the most sense and we can have scope slots and slots that get variables and a whole bunch. Of stuff. Kind of funny because I feel like this is back to the old angular set up for stuff which. Is well, if you look at few one and the first like Angular stuff that came out for web related things, it's very similar, but they moved out of that.
Like right now it's kind of away from it a bit, but the template bits are still there. So when you scroll up, you'll see that we have superbase and user. And then there's this concept in view now that's called composable and it's like a use something and you could see those as next or react hooks, but it has a slightly more stuff. You can do a bit more with it where you can encapsulate a whole bunch of stuff inside that function that you create. And then in you did it in React, it's all more in the open. It's a little bit more, it's less forgiving, but you can do more things.
And then I mean, few, it's kind of you have to go to the file and do everything there, OK. And it tends to output reactive related things, which is kind of nice. These are things that OK, they're coming from somewhere. Where where are your imports on this? OK, so that's what is again interesting in next here like the use super base client and use super base user come from the Super base module for next and they literally just expose them. Interesting.
Now there you go. I am not used to. No imports, nothing. If you make a component in Next and you put it in the components folder, it's just there. You just use it. There's no import needed. The thing is, you can turn that off. But the cool thing is because they have that feature, you can also say that component and put Lacey before it and it just hydrates it Lacey. That's why I was going to ask like there's. Some all that fancy stuff.
It's all in there because it's out-of-the-box for them. That Evan, you and team. Holy crap, the the guys at Knox and few it's there's like this is the thing. It's not as famous as like right now with Astro and and next and stuff, but all the things, all the, the, I'm not sure how controversial this is, but lots of things we see in those frameworks are actually Knox had that like last year, but they just didn't tell anyone. Yeah, I feel like that's the case on all of these. They're they're like, oh, that's cool. Oh, that's cool.
And they kind. Of, yeah, and we all kind of just align a little bit. How's how's how's the view on signals? Do they have something for signals already? I do not dare to say because I haven't used it, but probably if anyone here that uses few is in the chat please tell us. I'm. Sure they have. I'm I'm dying to know so it's felt five will have runes, which is basically signals coming out too. So OK, so in the.
End. They do similar things, right? So what to be able to make this work, let's go into Superbase and actually turn on this type of login behavior on the sidebar. There should be something with yeah, authentication. And then you can configure, I think go to providers, because here you can actually just do everything. It's ridiculous.
It's so cool. So we're using e-mail and it's already enabled, so we will probably need to go to URL configuration though to actually make that work. Oh, it's already local host, so that's cool. Let me quickly check my own Superbase, because we might have to put that redirect URL in also authentication configuration.
Yeah, So what I have in redirect URLs is just that local host and then slash confirm. So this is normally in Oauth, you have this confirm thing and you have a token and it sets everything up. This is similar with the e-mail magic link thing that they do. It comes back with the code, they do some stuff with Jason Web Tokens, set it up and then redirect you back and. I assume in in the actual code base you have a confirm file. Yes, you can see it there.
Confirm. There we go, sweet. And what it does, and that's like super easy. Now it just looks if there's a user with that composable that you get for free from the module and then we're watching that user because it's it's it's a, a reactive prop that comes out of it and it says immediate is true, which means I'm directly when this thing loads, I'm directly looking at if this thing has changed or not. And if it exists, it just redirect you to slash. And for me, like looking at this, this all seems like it's what sort of client side rendered right at this point. Right now this bit is client side rendered, but this could also be server side rendered.
That's the next. Sometimes you don't really know and so their default by now is actually it's all server and client at all times. OK, cool. And so if you really wanted to be just client, you can do dot client in the file name or there's a client only component you can put around some stuff. So just put your own e-mail address here and see what if it sends it to you.
Alex Coding. There we go. So you might want to go off screen to to to check your e-mail to see if you have a super based link. I do I will copy this clean link and go like this. And oh, it just the confirm was so fast that you're in now. So. We can now actually see the home page. Just just because like, I'm, I'm a nerd and I, I work for an authentication company.
So it's cool that we're checking this out. Yeah, exactly. I really wanna know what's floating around in here. Well, have a look if there's a Jason Webb token or something, there must be something that they've done. I should have probably cleared this first is. This a cookie. Perhaps they they said it. Here it looks like they have some next stuff. I don't know, maybe.
Don't kill me, but this this is kind of what comes back from Superbase and you'll see in here. So this is a JWT. Oh, you can decode it. That's cool. Yeah. So it's it's I didn't know that, yeah. And so you can look at what's coming back. And so the interesting thing on and we could probably spend a whole day diving into this, but. Authentication, yes.
The the cool part is like this is kind of your identifier that's sitting in there and that sub ID, but then it has our e-mail and like why it was provided it was through e-mail and that sort of stuff. But you can also, which I see right here, provide a bunch of user metadata. So like on Fusion auth, we we pass it's it's not only authentication, it's also. Well, it's a user database I imagine. Yeah.
So there's the customer identity side of things too, so. That's a really interesting bit, yeah. What you could do? Also you see that little icon below there with the next logo? Oh yes. So when you open this one, just click on the left one. Oh, left one. Yeah, the other one is just inspect. Oh, it's you're inspecting.
Literally. Yeah, when you click on this now, just and it will open and you can see, yes, I was and it actually opened. This is part of. The feed stuff because they have. This maybe that low level it's possible. That's really cool. But you can also see if you rather than inspect and go back, you can actually or you can just click get started because it and then here on the left, you can see all your props, all your modules.
And as a company like Superbase, you can make a Superbase panel here where you can just browse your database and do things you're. Kidding me? Yeah, it's insane. This is the most mature death tools I've ever seen. Yeah, I have never seen this level. All your icons here, there's Ogolia and there's like the people that worked on it, Superbase. This is ridiculous.
This is ridiculous. How sweet is that? That the next ecosystem is intensely good. Wow. But people don't know it somehow because everybody just uses React, right? Yeah, you're not wrong. OK, sorry, we're getting sidetracked. Anyways, we are here now, so which means we have, we actually have a token, we can see the thing. And so this is just next UI.
There's nothing else I've done now. So maybe the next thing we should do is go into Superbase and just make a table and fill it out quickly simply and just query that stuff and see what we can do. What are we thinking, cats? Yeah, why not? Why not? Right, we can just add a column for the name. OK, name the string.
Type should probably be text or something with like far char, but I guess text is fine. Yeah, just make a text for now. And what do? What else do we want So we have the name? Name. Color. How about color? We could. We could even make that like a enum somehow. Oh, if you want, sure we have to check though if we not, we probably have to make the enum first. OK.
Well, let's let's kill the. Let's save this one first. And now we can actually go and make an enum, but we let me just check where to do that. Yeah, I was gonna say where are enums? Yeah, so you go to the database tab and all the way down the first icon in the 2nd row, basically first time, two down. This one.
No, one more, one more. There we go. And that innumerable types on the bottom. Oh, nice all. Right. And then you can just create one. So we can do colors. Yep. And then what? Black Oops. Now we have what you can probably click add it on the little screen. Enter black. The fact we can do it like this is so nice and I know there's Postgres editor apps on iOS or on on Mac OS and stuff, but it's so nice to do it in the same project.
Yeah, that is really nice. And then I can come back to our table and edit the table. Yeah. So yeah, actually edit table and then add a column and just call it colour and there should be enumerable type just right there. Oh my. Goodness. It's incredible, isn't it? Yeah, that's really nice. I feel like we are hyping something that's super basic to these folks, but for us, that's freaking awesome. I feel like I've been living in, you know, Firebase land so long that like all these little nice things that used to be in my relational database world and SAP and stuff like, hey, here you go.
We we did that a million years ago. Yeah, exactly. For them this is like the basics, right? I kind of like this. So OK, maybe what we should do is just insert like two or three rows so we have it and then we can query it with the Super based. Stuff it would be really handy as if they just based on these types and things if it would automatically import a like a fake data kind of thing.
Let's not do that, all right? Where to next? One thing before we go, we have to put a policy on this so you're actually able to query. So there's the green thing on the top active RLS policies, yes, So we can actually make a new one on the right. There's new policy and we can probably go with the the full customization one because I think I know it's one that's relatively easy to add.
Where do I see my policies? Here we go. I'll just look at mine for a SEC. Edit OK, what's the policy name call? The policy name is just authenticated, users can do all the things or something like that. So just like auth. Yeah, sure. And So what we want to do for yeah, exactly, we kind of want to just click all for now. I know this is probably not the right way to do it. And then you can target the role authenticated. And we are going to just hack this thing by typing true in the expression here like everything is, let's just go if you're authenticated and do the thing.
Semi colon or anything? Let me check mine. Nope. Sweet. I don't think we need a true there, at least not in mine. Oh OK, OK, let's just do this and just pray that the guys from Superbase watching this don't say dude, what the heck. But I know for now this will work. But just so we know, for people watching, they can do incredible things with this. Yeah, dive in this.
Column. Is. Real, it's amazing, but for now at least, if you're authenticated, which you are, you have the JWT token, you can actually query this. So let's go to the code and I'll show you in composables. We made our own composable now, and I just call it use info, but we should probably call it use cats, right? We want to get cats, so let's rename it. And then on line one, it's also says use info. Now you can just use cats.
And so the cool thing about Nexus, it will just know this folder, it will import all these for you. You can just use it throughout the. Context like that that hurts my head a little bit, but. That's it's magical though, right? But sometimes to be honest, you don't know why something doesn't work or why it does work because some magic is happening somewhere, right? That's let's call this like what we see here is use async data and it's another use composable, right? And that's something that next gives you. So to do like an A top level await async data, that's key there that cats that you just put, that's actually the cache key that they will use while the app is running. So when you are in SSR mode, right, and you query cats, the next time you query cats, it will take the cache. That's really cool.
Well, that's super handy. That is. It becomes an async function where you can do whatever you want and you just return something. So right now we're going to return all of everything from cats. Awesome, I love it. What this thing does though, it's pretty cool that we shouldn't go too deep into now, but it has a bunch of features where you you can pick and transform whatever you get back.
Because what you see all the time, especially in the SSR rendered apps, is that you query everything. So it's a huge chunk of data, but you might only need two properties from each field from each object, right? And that's where, like the graph QLS of the world, you know you. Can graph QL does that natively. Obviously you just get what you want, but in this case you might get way too much.
And what you see all the time is people just query the dress thing, get everything. And then when you render on SSR, there's a script deck on the bottom that says window dot application state full of stuff you don't use. And that's that makes your app slow and it's big dumb. People don't pair that down. Nope, I've never seen that happen. Even I don't do that if you don't think about it, because it just works right.
And so in with this, they give you options to be able to say you know what, from these objects, I just want these fields or let me just transform them. And then you only have like a tiny bit. We're not doing that now because we. Don't I really wanted to like put it in here like name or something? Well, this is just a select, right? You can of course, this is just the this client that we created on line 5, that's the Superbase client. So if you just type name here, that's the query to Postgres. So of course you can just do name. I and I think that's that's going to be if I go back over here.
That will be that name. This name. So if I want a name and color, can we do? Just name, comma, color. Comma. That's what I was wondering. So this is now kind of like just a a postgres query. My guess is we'll probably need ID because we'll we'll probably actually need tier point all the fields. In this case yes, but in my case, when you saw my database huge, you don't.
Yeah, good point. So OK. Let's do this. And so now let's go back to our like, we go to pages and then index because we use file bases stuff. Yeah. So here let's make a script on the top. OK. Because we don't have any logic here now. And what do you want to do in the script tag itself? You can say setup which means it automatically just fires it up and you get top level await and stuff like. That are we doing anything like TypeScript where we need Lang? Yeah, we can.
Sure. So in the script tag itself, you type Lang equals TS and then you type setup after the gist on its own, like inside the script tag. It's not native, I know. Wow, OK. So we have a script setup now and in here it, this is by default async. So you can do a whole bunch of things and it it just you don't have to do any returns and stuff.
It just every cons you make in here is now assigned to the template. That's just some magic of the setup function. So we're going to do a weight and then yeah, because we it's an async function and then use cats as a function and I'm gonna. Stall that, by the way. I've never ridden this in my life. It's but it's kind of natural, I imagine, right? Very intuitive.
So what you can do now is just grab cats, copy paste it. And then right now let's see. So we're in the header. So remove that button. Just we don't need it. And I would say make a pre tag because we're gonna just dump some JS in here and then it's two curlies to open and then you paste. No, you don't have no, no need.
Nope. Oh, that's the beauty of you. Whoa. Oh, there it is already. Look. At that, isn't that fancy. That is fancy. It's doing some weird indenting, but. That's probably because you have a bunch of spaces somewhere before this. Can we check in the code if you remove the space on all the space on line 18? And I don't know, this might be it. No the before the.
The the Oh, I see what you're saying. Yeah, this, yes, that's just the nature of pre, I think, to be fair. Oh my God, it's nothing to do with that. I just. Spent like an afternoon out of work. There's you tailwind things on the pose this. Is all right. So we we yeah, this just comes out-of-the-box from the next UI. Super nice.
Do you see that drop down? They made that too. And the cool thing about this is it uses hatless UI components with all the accessibility HTML. All of it is in there and they just put stuff on top of that. Yeah, they wrapped it nice. That's it's very fancy. Can you can you customize the styling on all this? Yes, because it's all tailwind.
They just have Tailwind implementation. You can change the color and it's just, it just works. It's it's pretty ridiculous. That is, that's really cool. I love that the. Fun bit is like everybody who makes a NOx module to who contributes to the open source stuff. You get to use this for your docks. They just have a starter and it all looks good. It all looks the same.
That's cool. All right. What's next? What we need to do, you know, what we might want to do is add one more field to the database that's like a boolean of some sort, OK, Because I want to maybe filter on things like I don't know if they're vaccinated or not or something like that. Because we can then actually make like something and let's just vaccinated.
And then you just don't do a bull type. Yes. Did you fall or no? Maybe do falls by default because they're not because what we can do now with Algolia is filter on the fact that they're vaccinated. That's a great point, right? I'm just adding that in. So you might wanna, oh, I'm not sure if you can actually edit a row in here, can you?
Yeah. Holy moly, there we go. Let's let's, let's just do 2 with true and 10. That's very nice, I didn't even know this. You can just click. Double double click get to there. OK. So maybe make one of them vaccinated so we can filter on it. Zena is definitely vaccinated. There we go. All right, so now we go to the fanciness. Fanciness that is Algolia.
So without spending way too much time on coding something that will actually sync it to Algolia automatically even though we could, I have the code here in front of me. Maybe we just copy paste the Jason that we have in our pre tag. Do you think I mean we have we have 40 minutes we. Have like 40 minutes I.
Think we should try it because I think that's the power of taking like and pushing data to Algolia. That is power. OK, let me just have a look at my code of how I do it 'cause we can, we can actually pull it off I think. I think we can too. And then like maybe you can, if we are tight on time, you can send me like the snippets of search for their instant search.
And while you're doing that wonder should we, should we first take this data, put it in Algolia and actually show instant search? I think that could be cool. And then we do an automated mode. I love it. Let's do that. OK, yeah, this we're going to show. This like dark mode on here? Maybe I'm just missing it?
I don't think so, but they have new docks and that's not this. Oh, it's not. Yeah, there's like a a beta docks. This one maybe? Yeah, they sometimes they tell you, hey, go to the beta. Oh yes, it's up at the top. There we go. There we go. Look at how fancy this is. Yes, my eye. They also recently moved the whole community to Discord, so they're like, updated, yeah.
Yes. So for now, let's just seed it with this. OK. So we're in Algolia. You're going back to our. I'm going to my index. Yes, Scroll down all the way down. If you Scroll down, you see there's your index. You can click on it. That's that's the one thing for. I'll go there. Sometimes I'm like, hey, why is that not easier?
Yeah, it seems like that's kind of far down or something. I don't. Know it's because they offer so much more that's true using that right they have all these extra products in there were personalization recommendations all the things. That's a great point. I'm I'm looking for the dark mode in here, but not finance.
Sorry. Sorry folks, what's? Going to happen all right, so you can actually see add records. Oh, there we go. And we can just say manually, yeah, and just paste. Boop, boop. Nope, boop. There we go. Exactly, like sometimes I talk about this with my my boss Brian, who is actually ex Ogolia death row. And he, he told me Ogolia's so good they almost don't need death row because we're literally just doing it without anybody helping.
And this is pretty complex stuff, right? Yeah. And I I have to admit, there's probably more to the pulling, pushing data to Algolia than Algolia search itself because there's so much like done for you. Totally agreed. And that like there's, I did a, a stream with Chuck a few weeks back from Algolia where we actually explored like the more complex things once it's already in and it can go so deep, it's ridiculous. Like reordering of search indexes and things like that of of the results based on what people click on all the things. Yeah, we did.
We did one of those probably a year or two ago 'cause I was doing next GS and pushing our Firebase data up to it and then they. Seemed like you built this before. Yeah, I've done this in a different language for sure. Anyways, all right, so instant search. What you can do is show more attributes so we can have a little look at what and all the stuff that's here. Like there's just in the first one, if you go back, there's like a little link, like when you go to the first row of the data, there's like show, yeah, there we go. So now we see what we have.
So what we need to do now to be able to search through this stuff 'cause I made you a little instant search page already in the code base so we don't spend too much time with setup. I added just for now to keep it simple, little search box. So if we type something, we want to be able to see a result, right? So what we need to do is set up our index so we can actually search on, let's say, the name.
So you can just type name. And we probably also want to search if we type black, you want the color and vaccinated. I'm not sure because that's true or false. So that's I'm not sure you want to have that in your rich text search. Maybe this is fine for now. I don't really know what that does in this case.
We'll try. It we'll see what. Happens. Well, well, once you have this, what you can do is later on add ranking and sorting and relevant sorts and a bunch of very fancy things we. That stuff's amazing, by the way. I love that stuff and this stuff. Lots of words, lots of times stuff in that sentence, yes.
As far as I remember, if this is searchable, you can have a little search box on top of your list of facets and you can actually filter your facets to be less, but I'm not entirely sure if that's it. I'm hoping Chuck or Julie or someone else goalie is watching so they can they can help us here. I can send the comments if you're watching, there's a few of you out there.
So we have the Algolia module in next GS that we're using. However, if you want to use instant search, that's a package that they build. So we're kind of using both now. So as you can see on line 9, it says use Ogolia ref. That's the reference to the Ogolia client, and that comes from the next module. It just does the magic for you to set up all of that. We don't need to touch anything.
We have the index name already. So now what you see, we have the index name and we have the Algolia reference to their client and this EIS Algolia instant search tag. This is basically setting you up for search and we've set up our client and our index name and then the components that come out of that package, you just can put them in there and it's and stuff happens. And is.
We put columns. I don't know why. Got it. You know what, If you want to be fancy, you can do JSX in few no problem. Oh. I and I am a huge fan of JSXI. Just like same here. It's templating in here. So it's not fully my thing, I had to get used to the colon thing, but it works fine. Are you familiar with Like what's the ES here? Yes, so this is an interesting bit here. Few instant search for few three has a few different packages and that's because if you do use this without Nuxt or when you use it with Webpack 5, it might need that you need the UMD bundle or the CGS bundle and next is very particular with what it wants because it has feet running underneath. They have opinions and once they match, they can do all their black magic right.
And so that's why we get the ES1 and then we don't need to do anything complicated here because. That's ecma ECMA script right? ESI believe. I think it's ES modules. OK, ES modules that makes. More sense. So there's different things you can do here. Like if you didn't want to do that ES modules thing, you can also go to the next config and then deep go deeper into say in feet load this thing like that.
If you don't have to do that, it's much nicer, right? Yeah, for sure. Oh, it's already working OK it. Seems that way, yeah. It doesn't look great, but it works. So we have the object ID. Well, it's already reserved well, we're just not showing something nice here. Yep. So we're getting the which index it is and what the ID is inside our dashboard. So I will mention to people, and I don't know how to do this in view, but when I was running next, yes, I had searched the instant search on my all my pages. So it was on my main page.
There is a way in there to set, don't go fetch anything until I type. So that way you're not getting that hit and it it's a Oh yeah. You can. You can do a bunch of that stuff, I just chose not to right now. It just shows you everything and you filter down essentially. Cool. Can we set up some cool styling for this?
Shall we make that look a little better? A little better. OK, if you go into the next config JS file or TS file on in your sidebar. Oh there we go. Right now you can see I set the theme to reset AH. OK. And let me just Google because I think there's another theme that you can use maybe if you just don't put a theme, if you remove that, OK, it might just yeah, if you just.
And normally it should just rebuild now. Knox gets a little crazy when it's rebuilding. Well, that's a little intense. OK, so now we get the. IT doesn't look that awesome just yet. And I'm super zoomed in, so Nope, doesn't make the difference hard. So if you want, I can give you something that's like super fancy here.
Yeah, dump it. Dump it in private or in a discord. It's either way. Because honestly, this kind of needs to look a little bit better, right? Yeah, it looks so. It looks rough. What I have done is something quite fancy because I've actually used Algolia Instant Search and then I, I kind of killed their HTML and used my own and I used Knox UI. So it's full Knox UI styling and HTML, but Algolia data. The thing is I can just post this whole file to you. It however, has all the properties that I use in my database.
So there's a bunch more properties, sure, but we could put it in and just scale it down and see if it works, right. Let's do that. So I think I should probably in discord send you the file on its own. That'll work. Or should I wait just go to GitHub? I think it open sourced the thing. Go to GitHub slash Tim Bannix.
Oh, OK. And then we'll just find it. We can just copy it from there. And then just my repository. So not this one, can you? Yeah, let's see. Yeah. So the second one, yeah, that's French stuff again. And then find pages Cat's index. Pages Cat's index view. Yeah. So this is pretty intense. There's kind of a lot, but let's copy this. OK.
And then we just scale it down in complexity. All right, so let's just start at the beginning. You can see I have a bunch of extra options here. I also add history and routing so the URL reflects what you search. When you click on. That's really cool. Because I wanted to do that so I could make links for people that says I want to get this thing filtered by host families or something.
So it's like a URL you can link to. So you can see I have this Lieblesia on line 20. We need to make that your index name. This. Yep, I didn't get that. Yeah, isn't it? Oh yeah, same. The the great part is I have Ray cast so. Oh, yeah, I don't. I, I could not get used to it. The thing is, you can see that import for the helpers.
Let's kill that because we don't have that here. So I have a little translation thing. Just kill it. We don't need that. Cool. There's some links here that just fine and you see I have a bunch of columns here. So we have name, color and vaccinated. So we can remove a bunch of stuff and just add vaccinated and like on line 34. Just let's make it an English name also. Oh.
Yeah, some French stuff going on here. All right, so we have some column selection. You see, here I do a translation of the label. You can probably just keep it like this. Oh you know what? Instead of removing it on line 51, just remove the function itself. The whole thing. I'm going to just just comment it out again so that it's so it works and remove that function translate label. So just return item dot label rather than the function. Oh, gotcha.
You are dealing with MVP alpha code. In my case, I might not do this again, but at least it works. And now we just needed a comma. Yeah, when you select it, it goes to another URL. We probably don't need that because we don't have another URL. So remove the whole function and then we can later on on the table definition we just remove that select thing.
That's where I was like, yeah. It's somewhere below. Just find. Yeah, just find. Yeah, yeah, that one. Just remove this because we don't have no the whole thing we need just select below OK. Gotcha. There we go. So there's a few things we need to change because I'm looking for certain things to filter on for facet and I kind of hard coded that because I have a set database.
So when we scroll up all the way to the beginning, you'll see that I'm using you page with a template on the left that has an aside you see on line 77. And in the sidebar. I actually use a refinement list that looks for something called facets. Because what I've done in my database, when I send it to Algolia, I look at like 20 different fields, and if they're true, I just push them in the facet list so there's an array that it can filter on.
We don't have that at all. So what we might want to do rather than facets here is actually type color. Sorry, attribute is color. Yeah, and sort by you can just remove transform items is I forgot what I coded for that. Oh, that's this thing. We're good, we're good. And then there's a whole bunch of like this slot stuff again to make all this work with Next UI. OK.
So this is kind of hackery, but you can use all the loveliness for Mongolia's engine and make it look like Next UI by doing this. And they're both so extensible that it just works. It's pretty magical. Yeah. And so like basically you're taking in item and it's fed in from. Yeah, So what this is called is a scoped slot and the slot gets variables from the function of the component called AIS refinement list that Algodia built.
And add change. If you put an add, it's always an event that either something that bubbles up from the child component that you can just push as an emitter or it's a native thing. Perfect. And in this case it's you checkbox, right? So this is you next UI checkbox. So they have a custom event that they let bubble up and you can just wait for the change and then it refines cool and refines function from Ogolia again.
And then we've just got a divider. We can keep, but the next one, this is looking for the host family. We don't have that. We have vaccination, right? So instead of host family dot ID, dot name, we just type vaccination or vaccinated. What was it again? Yeah. I think that's it. And I think that's literally the same. We can just.
Double check over here. And yeah, let's let's be safe. Vaccinated, vaccinated. Perfect, perfect. The H3 three you probably will want to type vaccinated there. H3H3. On 110. Thank you 10 this. Yeah, 'cause this is French stuff we don't need. Oh, we might want to do that. For the previous one we changed as well to call it color rather than status. Perfect.
All right, I think we only need those two. Whatever is below, there's some more faceting going on. We can just remove that. So this one we don't need. We also don't need their sacs because we didn't fill that out. And that's that should be Yeah. So let's see what do we have left? I think we're good.
And this is like another slot that you get from the sidebar and in the top of the sidebar we just make make it like show some links. Cool. And I think the next one is the hits. So it shows you all the results. I'm familiar with that. It's it's funny that this items is not like more called out to me. That's that's the only weird thing I'm trying to get used to in view.
Honestly, that's kind of strange in few land because these slots that you get and you get data from the parent component essentially. I would like to know like what my options are, you know? Exactly. And it's kind of, but that's why it is in these curlies, because you get more, you don't need the curlies and you get everything.
But The thing is, it's not typed in a sense that you can now see what comes out. Yeah, that would be nice. It's a bit weird in that sense, but it's so powerful because what can come from there are functions, variables, objects, stuff, arrays of things. It's kind of all of it. Cool. Oh yeah, this is a button to make a new cat. We haven't built that, so we probably don't need that. There's our search box that yeah, let's just call this search cat.
Nothing else we need there. It's refining, searching. And then there's a column selector. That's kind of cool. And then there's the table that just shows all the rows we just added. I think we're good. Let's find out. So we went deep. We didn't use the out-of-the-box stuff now, but I'm kind of happy that there we go.
It just works. Holy, holy. Here's Xena there we. Go. I don't see the sight, Mardo. Hang on, let me, maybe I'm zoom issue no. That's interesting. Yeah, can I use those dev tools to to search maybe? We should be able to. Looks like I got some issues. There's some some warnings that, well, maybe we should ignore these for the time being. Patients.
It gives you a bunch of stuff, but we can use it for free when you're just developing. So let me just give it to you what you need to do, because it's actually easy. Oh, just go back to the, the, the GitHub. Yeah. And so go to Next confic. And then when you're on the top, you see in line three it extends Next UI Pro. OK.
I think we're cooking. Oh. There we go. Cool, now when we do this we get all the nice filtering. Is it working? Holy moly. Yeah, it looks. Looks great, a little jumping around but. Yeah, that's because the moment you filter it removes something from the list, and there are ways to change that, but I just didn't do that here. Yeah, it's all good.
And now we're kind of the vaccinated one with true and false is kind of strange, right? Oops. So what do you want to do for that, to make that work in Algolia is if it's vaccinated, you push vaccinated in, and if it's not, you don't. And so then it can say vaccinated with a checkbox. Right now, it just has a failure. True and false.
You can just remove. I totally thought that was our color changer. I wasn't even paying. Attention I just I, I just. This is was it like but this is not Algolia, this is just next UI. Oh wow, that's cool. And they just built that in and you can even order the table, but you don't want to do that because we have Algolia. That's amazing.
Algolia gives you the data for the table and you should do the ordering with that. And is this doing highlighting or it's not? No, I did. I just didn't build that in. But you can. Yeah, so like for instance, I'd, I wish I had my old site, I should have put it on a old like domain name when you go through the search. So instead of like on coding cat, now I feel like I'm going to have to talk with the L Golia people. I just did a more localized search. So when you go to search so when it highlights like that. Fancy.
There's AAIS highlights I believe for. Instant. Search and it will. We'll put that on there for you, so. I just didn't put that in, but now that you told me I should actually do that. Very cool. So we're like we have like 14 minutes. Do you think we can get to pushing data? Yes, let's do it. So the the it's kind of strange though. So what we should probably do for now is just grab that data from the database and statically put it in somewhere and then hit a button and send that over.
Because if we wanted to change something in the database and based on that change, then push it in Algolia, we have to build like a whole CRUD app to do that. And I don't think we can do that in like 13 minutes. OK, So what we can do though is if you go to GitHub again. And just a random question 'cause I mean super base can you actually set up functions 'cause I used to do this in Firebase where every time you did an update in the database the function would just push to Algolia.
Is that a thing? Yes, I just didn't build that. I think it has that because they all have serverless functions for example. Yeah, they do, right. Nice. Oh shit, sorry to to say that online, but you actually just gave me a really good idea because I put all of that when I save something in oh, sorry, in Superbase, you see it updated on the screen and then I have a custom function that I just say update or go here.
We just do that now, Should we? Should we take 12 minutes to figure out if that's possible? We'll take 12 minutes and see how far we can get right. Yeah, because you I expect APR soon from you. No, Yeah. No problem. All right, So what we'll end up doing? We'll just share a screen again and let's have a look. Yeah.
So I think we have to go. That is pretty awesome. There has to be like a like it'll be a node JS set up. I'm curious if any community members have a super base 2 Algolia. Function or something? There must be something I just I just didn't check. Pipe dream, you dumb thing. Yeah, this is so silly, isn't it? I just have an idea of how to code it, so let's just code it, but maybe something exists.
Here we go. Oh, this is just full text search itself, so you don't need Algolia, no. No, no, this is, this is with Algolia, right? Am I wrong? No, I don't think so. I am wrong, sorry. Yep, you're right. The thing is, if you are a database person like a lot of people are, you don't need Algolia for this because you can just do indexes. Yeah, on the your postgres, right. The thing that Algolia provides, and this isn't just me pitching it because they've sponsored this episode, there's so much. What's the word I'm looking for?
Re ranking, synonyms, analytics, all the things you want. So maybe we should find out in the last 10 minutes now if we can fire a function some of some kind when a database Rd. changes. Yes maybe we can Google for that, like fire function based on road change or something. Maybe it's time to ask John to jump in and ask.
Help us. Just talk to him, which would be my last night, his today. He might have crossed over. John lives in the future, folks. He's in Australia. So Oh yeah, exactly update data that it's all client related. Yeah, there has to be a trigger function Superbase trigger. If we cannot find it in the coming few minutes, I'll just show you how I did it and then people have an idea of how you could do that. You can schedule let's.
Yeah, that's exactly it. But where does the code live? That's my question. I don't understand where if if you execute this inside of superbase that will create that I think. Yeah, just go to SQL Editor. I don't know. This isn't like SQL though, right? Is it? Oh, but this is. This looks like an SQL function or something. Your language is PLPGSQL.
Exactly. So go to Lib helpers and find the update cat function. And you might want to zoom in a bit. It's on line 48. Yeah. So basically in like you can see this is this looks really silly, but I don't want to save all the data into the database that is sent to Algolia. The database just has to clean stuff like the fact that a cat is adopted. It's a checkbox, true or false, right? But I don't want to send true or false to Algolia. So I'm just whatever the cat object is that I have on the page is quite different than what's actually in the database. So I kind of re clean it up.
So this is what I sent to the database and when you Scroll down a bit more like all the fields, then I have this update Algolia of the same object that was actually on the page. So not what goes to the database. So can you find the update algolia function should be below this I think or so I'll just maybe want to just is there.
Oops, this one. Yes, and so here I'm actually grabbing the admin API key from Mongolia and not just the normal one. I make it Algolia search like I'm importing this on the top of this file, right? I make their search. This is just their node API. And so I initialize the index and then line 295 is horrible.
Read that and weep. You know why this is in Fuji S when you have a proxy, which is a reactive thing, it's not just an object that can send over the wire because it's a reactive thing with all its functions and fanciness. And I did not Google, I just knew from two years ago that this was how to make it non reactive but just a Jason object. I think lots of few people are crying now when they watch this. There's probably a function to make it non reactive and just half your object, but this is how I did it. Yeah, if you're on the newest piece of of next, there's actually a copy object of function built into to JavaScript now, so.
I'm. Sure, I'll have to share that. With you if you have that so. You don't cry. Anyway, So what I do, I make an object ID. That's just the normal cat ID information, my database, because Algolia worked with object IDs. And as you noticed when we pasted our stuff, there was not an object ID, they just made you one.
But I kind of wanted this to be able to query one thing later. I wanted my own ID and so let's see. So I feel like you can also make just ID if you were to move that over indexable as well. So it would kind. Of probably yes and literally the only thing I did is save object, so not save objects because save objects is for all of them and this is just one and if it doesn't exist, just make it. There is one function that it seems I have not I don't see here yeah.
So it queries the families table and it queries the treatments and the weights and it makes one big object of everything for that cat. And that's what we're dealing with here and that's what's going into Algolia also. So actually what you would do, you would take exactly what Tim has written here. You would take all of this stuff into a function that runs on Superbase and just trigger this every time the database updates instead.
Exactly because the code I just used here, that's just node, right? Like it's. It might be in a JavaScript file, but it's essentially just. You can run this in Node GS and just do this. Yeah, and and they'll run out on Dino is their edge functions, it'll run the same way. So. Yeah, and great example. One thing is you have to hope that the Superbase SDK or the Super base will probably work.
But the Algolia SDK works on on Bun or Dino or whatever it is, so we don't know. We'll have to check that. Yeah, for sure. Well, I think this was a great representation of how to build a SAS, which you have much more baked. Do you plan on giving that to the world once you're done or? It's the plan to finish this thing because these people I built this for, they're all struggling and why not give them this and a simple page builder so they can get donations and share stuff on Facebook and have a database of cats because they don't know, don't even know to which families the cat was went to.
And that might not sound so bad, but sometimes, and we're dealing with that right now because we are one of those families. The previous family didn't clean well in their house. So the cats get sick, but they're not sick when they're in that place. They're sick when they come to my house and then infect my cats or give me scurvy or some crazy things, you know, whatever. And so you need to deal with that stuff and have a paper trail.
It's really important. So you guys don't, do you do microchipping over there or no? Yes, they all have. And so the idea for me now is to build this thing so they all got a database and that like right now this is just for one. But the point is I will make it so you have multiple associations in the system and then when you make a new user account, you're just associated to one of them so you cannot see the rest and all the cats fit to an association as well.
You can make accounts and you can give your friends accounts and then you can make your website. And then I make a bunch of fun integrations to share this cat on Facebook from the tool and it will just do it like all these kind of like little helper things. And it can grow as big as receive a donation or sell this mug so you get money for your association.
And for now I thought maybe I'd give it to them for like 5 bucks a month and I host their website and do the whole thing. I might just give it for free. Depends how many people want this thing. Yeah, I mean, maybe you give it to the people and have like an organization, like a shelter or something. Pay the five bucks you.
I really appreciate it. Come on, anytime we'll build something cool, OK? We will. And you know what? Actually I didn't know these like these tools combined made me start this in a weekend. And if I had been slightly more full stacky and understand databases a bit more, you could build your basics of your SaaS with this tool chain in in 2-3 weekends and you're good.
