Isomorphic JavaScript client for Supabase providing authentication, database, real-time, storage, and edge functions capabilities.
89
Build a simple task management system that allows users to perform basic operations on tasks stored in a Supabase database.
Implement a task management module that provides functions to create, read, update, and delete tasks from a database table. The system should handle tasks with the following structure: id (number), title (string), description (string), completed (boolean), and priority (number).
The module should support:
The database connection should use environment variables SUPABASE_URL and SUPABASE_KEY for configuration.
getAllTasks function returns all tasks from the tasks table @testgetTaskById function returns a single task matching the provided ID @testgetCompletedTasks function returns only tasks where completed is true @testgetIncompleteTasks function returns only tasks where completed is false @testcreateTask function inserts a new task with title, description, and priority @testupdateTask function updates a task's fields by ID @testdeleteTask function removes a task from the database by ID @test@generates
/**
* Initialize and return a Supabase client instance.
*/
export function getClient(): any;
/**
* Retrieve all tasks from the database.
* @returns Array of all tasks
*/
export async function getAllTasks(): Promise<any[]>;
/**
* Retrieve a single task by ID.
* @param id - The task ID
* @returns The task object or null if not found
*/
export async function getTaskById(id: number): Promise<any | null>;
/**
* Retrieve all completed tasks.
* @returns Array of completed tasks
*/
export async function getCompletedTasks(): Promise<any[]>;
/**
* Retrieve all incomplete tasks.
* @returns Array of incomplete tasks
*/
export async function getIncompleteTasks(): Promise<any[]>;
/**
* Create a new task.
* @param title - Task title
* @param description - Task description
* @param priority - Task priority (1-5)
* @returns The created task with ID
*/
export async function createTask(
title: string,
description: string,
priority: number
): Promise<any>;
/**
* Update an existing task.
* @param id - The task ID
* @param updates - Object containing fields to update
* @returns The updated task
*/
export async function updateTask(id: number, updates: any): Promise<any>;
/**
* Delete a task by ID.
* @param id - The task ID
* @returns Success confirmation
*/
export async function deleteTask(id: number): Promise<void>;Provides database client for performing CRUD operations on the tasks table.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-supabase--supabase-jsevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10