Isomorphic JavaScript client for Supabase providing authentication, database, real-time, storage, and edge functions capabilities.
89
Build a product inventory query system that retrieves products based on various filter criteria.
You need to implement a module that queries a products database table and returns filtered results based on price ranges, stock levels, and rating thresholds. The database connection is already configured.
The products table has the following structure:
id (integer): Unique product identifiername (string): Product nameprice (decimal): Product price in dollarsstock (integer): Quantity in stockrating (decimal): Product rating (0-5 scale)category (string): Product category@generates
import { SupabaseClient } from '@supabase/supabase-js';
/**
* Get products with exact rating
* @param supabase - Supabase client instance
* @param rating - Rating to match exactly
* @returns Promise with products matching the rating
*/
export async function getProductsByRating(
supabase: SupabaseClient,
rating: number
): Promise<any[]>;
/**
* Get products with exact price
* @param supabase - Supabase client instance
* @param price - Price to match exactly
* @returns Promise with products matching the price
*/
export async function getProductsByPrice(
supabase: SupabaseClient,
price: number
): Promise<any[]>;
/**
* Get products above minimum price
* @param supabase - Supabase client instance
* @param minPrice - Minimum price threshold (exclusive)
* @returns Promise with products priced above the threshold
*/
export async function getProductsAbovePrice(
supabase: SupabaseClient,
minPrice: number
): Promise<any[]>;
/**
* Get products at or below maximum price
* @param supabase - Supabase client instance
* @param maxPrice - Maximum price threshold (inclusive)
* @returns Promise with products at or below the threshold
*/
export async function getProductsBelowOrAtPrice(
supabase: SupabaseClient,
maxPrice: number
): Promise<any[]>;
/**
* Get products within price range
* @param supabase - Supabase client instance
* @param minPrice - Minimum price (inclusive)
* @param maxPrice - Maximum price (inclusive)
* @returns Promise with products in the price range
*/
export async function getProductsInPriceRange(
supabase: SupabaseClient,
minPrice: number,
maxPrice: number
): Promise<any[]>;
/**
* Get products with stock above threshold
* @param supabase - Supabase client instance
* @param threshold - Stock threshold (exclusive)
* @returns Promise with products having stock above threshold
*/
export async function getProductsWithStockAbove(
supabase: SupabaseClient,
threshold: number
): Promise<any[]>;
/**
* Get out of stock products
* @param supabase - Supabase client instance
* @returns Promise with products that have zero stock
*/
export async function getOutOfStockProducts(
supabase: SupabaseClient
): Promise<any[]>;
/**
* Get products with low ratings
* @param supabase - Supabase client instance
* @param threshold - Rating threshold (exclusive)
* @returns Promise with products rated below the threshold
*/
export async function getLowRatedProducts(
supabase: SupabaseClient,
threshold: number
): Promise<any[]>;
/**
* Get highly rated products
* @param supabase - Supabase client instance
* @param threshold - Rating threshold (inclusive)
* @returns Promise with products rated at or above the threshold
*/
export async function getHighlyRatedProducts(
supabase: SupabaseClient,
threshold: number
): Promise<any[]>;Provides database query capabilities for interacting with Supabase backend.
@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