TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

⚡️ CRUDify Supabase Tables ⚡️

This is a wrapper around @supabase/supabase-js that generates CRUD actions (like Prisma) to manage tables' data.


  1. Install libraries
yarn add @supabase/supabase-js supabase-js-crud
  1. Create supabase client
import {createClient} from '@supabase/supabase-js';

const supabase = createClient('', 'public-anon-key');
  1. CRUDify your tables
import {DBTable} from 'supabase-js-crud';

const db = {
  shop: new DBTable(supabase, 'shop'),
  product: new DBTable(supabase, 'product'),

const shops = await;
const oneProduct = await db.product.findOne({where: {id: '123456789'}});

CRUD methods

  • create: (params: CreateParams<T>, options?: DBTableMethodOptions) => Promise<T[] | null>;
  • createOne: (params: CreateOneParams<T>, options?: DBTableMethodOptions) => Promise<T | null>;
  • find: (params?: FindParams<T>, options?: DBTableMethodOptions) => Promise<T[]>;
  • findOne: (params?: FindOneParams<T>, options?: DBTableMethodOptions) => Promise<T | null>;
  • update: (params: UpdateParams<T>, options?: DBTableMethodOptions) => Promise<T[] | null>;
  • updateOne: (params: UpdateOneParams<T>, options?: DBTableMethodOptions) => Promise<T | null>;
  • delete: (params: DeleteParams<T>, options?: DBTableMethodOptions) => Promise<T[] | null>;
  • count: (params?: CountParams<T>, options?: DBTableMethodOptions) => Promise<number>;

TODO: add more detailed description for params and options types. For now, you can check them in types and they are mostly intuitive.

Global methods

  • registerActions(...) lets you register handlers for global actions such as onError that might be useful if you develop separate API server.
import {registerActions} from 'supabase-js-crud/dist/help';

  onError: error => {
    throw new InternalServerErrorException(error);
  • registerConstants(...) lets you register global constants which are used in CRUD actions such as default value for take. By default, it's 25.
import {registerConstants} from 'supabase-js-crud/dist/help';

  take: 50,


You can also provide a model class to DBTable so IDEs will help with autocompletion.

type Shop = {
  id: string;
  created_at: Date;
  updated_at: Date;
  name?: string;

const shopTable = new DBTable<Shop>(supabase, 'shop');
const oneShop = await shopTable.findOne({where: {name: {like: '%Supa%'}}});

For types generation, check out Supabase docs.


  • Create a new shop with name SupaShop:
await{data: {name: 'SupaShop'}});
  • Get active products and a related shop:
await db.product.find({
  where: {status: 'ACTIVE'},
  include: ['*', 'shop:shop_id (id, name, status)'],
  • Get 20 active products with category name Bags ordered by created_at (descending):
await db.product.find({
  where: {status: 'ACTIVE'},
  include: ['*', 'shop:shop_id (id, name, status)', 'category:category_id!inner (name)'],
  innerWhere: {
    '': 'Bags',
  order: {by: 'created_at', ascending: false},
  take: 20,


  • [ ] Better docs and more examples
  • [ ] Article with the library usage?

Feel free to open an issue for suggestions as the library is in the beginning stages.


If you face any issues with the library, please, open an issue with the detailed explanation.


Credits go to the amazing team behind the awesome Supabase project!


This project is MIT licensed

Package Sidebar


npm i supabase-js-crud

Weekly Downloads






Unpacked Size

41.5 kB

Total Files


Last publish


  • kanzitelli