npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

supabase-js-crud

v0.0.1

Published

CRUDify Supabase Tables.

Downloads

32

Readme

⚡️ CRUDify Supabase Tables ⚡️

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

Quickstart

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

const supabase = createClient('https://xyzcompany.supabase.co', '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 db.shop.find();
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';

registerActions({
  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';

registerConstants({
  take: 50,
});

Models

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.

Examples

  • Create a new shop with name SupaShop:
await db.shop.createOne({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: {
    'category.name': 'Bags',
  },
  order: {by: 'created_at', ascending: false},
  take: 20,
});

Enhancements

  • [ ] 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.

Troubleshooting

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

Credits

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

License

This project is MIT licensed