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

@pixpilot/supabase-camel

v0.4.2

Published

TypeScript utilities for Supabase with automatic camelCase/snake_case conversion.

Readme

@pixpilot/supabase-camel

import { keysToCamelCase } from '@pixpilot/object';
import { SupabaseClient } from '@supabase/supabase-js';

export async function dbSelect<T>(
  client: SupabaseClient,
  table: string,
  filters: Record<string, any> = {},
): Promise<T[]> {
  const { data, error } = await client
    .from(table)
    .select()
    .match(keysToSnakeCase(filters));
  if (error) throw error;
  return keysToCamelCase(data) as T[];
}

This keeps your business logic clean and schema-agnostic.

TypeScript utilities for Supabase with automatic camelCase/snake_case conversion. Keep your code camelCase while your database stays snake_case.

Installation

npm install @pixpilot/supabase-camel

Quick Start

import type { Database } from './database.types';
import { createCamelCaseDb } from '@pixpilot/supabase-camel';
import { createClient } from '@supabase/supabase-js';

// Create your Supabase client
const supabase = createClient<Database>(
  process.env.SUPABASE_URL!,
  process.env.SUPABASE_ANON_KEY!,
);

// Wrap database operations
const db = createCamelCaseDb(supabase);

// Use camelCase everywhere!
const { data: users } = await db
  .from('users')
  .select('*')
  .eq('isActive', true)
  .order('createdAt', { ascending: false });

// users is an array of user objects

Usage Examples

Select Queries

// Simple select
const { data: users } = await db.from('users').select('*');

// With filters
const { data: activeUsers } = await db
  .from('users')
  .select('*')
  .eq('isActive', true)
  .like('name', '%John%')
  .limit(10);

Insert

const newUser = {
  userId: 'unique-id',
  name: 'John Doe',
  email: '[email protected]',
  isActive: true,
};

const { data: insertedUsers } = await db.from('users').insert(newUser);
// insertedUsers is an array containing the inserted user(s)

Update

const { data: updatedUsers } = await db
  .from('users')
  .update({ isActive: false })
  .eq('userId', 'some-id');
// updatedUsers is an array of updated user(s)

Delete

const { data: deletedUsers } = await db.from('users').delete().eq('userId', 'some-id');
// deletedUsers is an array of deleted user(s)

Upsert

const { data: upsertedUsers } = await db.from('users').upsert([
  { userId: 'id-1', name: 'User 1' },
  { userId: 'id-2', name: 'User 2' },
]);
// upsertedUsers is an array of upserted user(s)

Type Safety

import type { CamelCaseInsert, CamelCaseRow } from '@pixpilot/supabase-camel';

// Typed row data
type User = CamelCaseRow<Database, 'users'>;

// Typed insert data
const newUser: CamelCaseInsert<Database, 'users'> = {
  userId: 'id',
  name: 'John Doe',
  // TypeScript autocomplete works!
};

Using Auth, Storage, etc.

Only database operations are wrapped. Use your regular Supabase client for everything else:

// Database queries with camelCase
const { data: users } = await db.from('users').select('*');
// users is an array of user objects

// Auth, storage, etc. - use original client
const {
  data: { user },
} = await supabase.auth.getUser();
const { data: files } = await supabase.storage.from('avatars').list();

Available Methods

All standard Supabase query methods work with camelCase:

  • Filters: eq, neq, gt, gte, lt, lte, like, ilike, is, in, contains
  • Modifiers: order, limit, range
  • Operations: select, insert, upsert, update, delete

Utility Functions

import { keysToCamelCase, keysToSnakeCase } from '@pixpilot/supabase-camel';

// Manual conversion if needed
const camel = keysToCamelCase({ user_name: 'John', created_at: '2024-01-01' });
// { userName: 'John', createdAt: '2024-01-01' }

const snake = keysToSnakeCase({ userName: 'John', createdAt: '2024-01-01' });
// { user_name: 'John', created_at: '2024-01-01' }

Features

  • ✅ Automatic case conversion for all database operations
  • ✅ Full TypeScript support with Supabase-generated types
  • ✅ Method chaining with type-safe filters
  • ✅ Zero dependencies (built-in conversion)
  • ✅ Works with existing Supabase client configuration
  • Optimized for edge functions (5-15ms overhead per query)
  • Smart caching for column name conversions
  • Memory efficient (< 50KB overhead)

Performance

This library is optimized for production use, including edge functions:

  • Minimal overhead: 5-15ms per query (including long chains)
  • Smart caching: Column name conversions are cached for ~50x faster repeated access
  • Memory efficient: < 50KB total overhead
  • Edge function ready: Tested and optimized for Supabase Edge Functions

Benchmarks

| Query Type | Expected Overhead | | ------------------ | ----------------- | | Simple select | 2-3ms | | With filters (2-3) | 4-8ms | | Long chains (5+) | 10-15ms |

For detailed performance analysis, see PERFORMANCE.md.

License

MIT


Made with ❤️ by PixPilot