> ## Documentation Index
> Fetch the complete documentation index at: https://boilerplate.loopple.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Database - Supabase

> Details about the database that you get in the boilerplate

## Managing Projects with Supabase

### Using Supabase for Database Management

We utilize [Supabase](https://supabase.io/) for managing our projects database.
Below are the functions used to interact with the Supabase database. These functions
can be found inside `src/pages/dashboard/projects.js` file.

#### Fetching Projects

The `getProjects` function fetches projects from the Supabase database.

```javascript theme={null}
async function getProjects(supabase) {
  const { data, error } = await supabase.from("projects").select("*");
  if (error) {
    console.error("Error fetching projects:", error.message);
    return [];
  } else {
    return data;
  }
}
```

#### Adding a Project

```javascript theme={null}
async function addProject(supabase, projectData) {
  const { data, error } = await supabase.from("projects").insert(projectData);
  if (error) {
    console.error("Error adding project:", error.message);
  } else {
    console.log("Project added successfully:", data);
  }
}
```

### Setting Up a Supabase Database

If you haven't already set up a Supabase database, follow these steps to create one using the SQL editor:

1. **Visit the Supabase Dashboard**: Go to the [Supabase Dashboard](https://app.supabase.io/) and sign in or create an account if you haven't already.

2. **Create a New Project**: Click on the "New Project" button to create a new project. Follow the prompts to set up your project.

3. **Access the SQL Editor**: Once your project is created, navigate to the SQL editor from the left sidebar menu.

4. **Create a Table for Projects**: Use the SQL editor to create a table named "projects" with columns for the project data, such as project name, description, etc. Here's an example SQL query:
   ```sql theme={null}
   CREATE TABLE projects (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    title TEXT,
    description TEXT
    )
   ```
