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 🙏

© 2026 – Pkg Stats / Ryan Hefner

piquel

v0.3.1

Published

Type-safe PostgreSQL database library with schema generation

Readme

Piquel

Typed raw PostgreSQL queries with optional Zod validation and schema generation.

Read the full documentation

import { z } from "zod";
import { createDatabase, createOperation, sql } from "piquel";
import { schema } from "./generated-schema";

// Wrap a pool in a database facade
const db = createDatabase({
  pool: somePool,
  useZodValidation: process.env.NODE_ENV !== "production",
});

// Create a reusable operation
const getUserById = createOperation(
  ({ userId }: { userId: number }) =>
    sql`SELECT user_id, name FROM app_user WHERE user_id = ${userId}`,
  z.object({
    user_id: schema.app_user.types.user_id,
    name: schema.app_user.types.name,
  }),
);

// Use the operation
const user = await db.client.queryOne(getUserById({ userId: 1 }));

// Or use the operation inside a transaction
const updatedUser = await db.transact(async (tx) => {
  const userId = 1;
  const userBeforeUpdate = await tx.queryOne(getUserById({ userId }));

  await tx.nonQuery(
    sql`UPDATE app_user SET name = ${userBeforeUpdate.name.reverse()} WHERE user_id = ${userId}`,
  );
  return tx.queryOne(getUserById({ userId }));
});

Installation

npm install piquel zod

# Piquel is not a database driver — you need one separately (e.g., pg)
npm install pg

piquel requires Zod v4 (zod@^4).

Features

| Component | Description | |---|---| | Database facade | Wraps a pool and exposes query, queryOne, queryOneOrNone, and nonQuery with optional Zod validation | | SQL builder | sql tagged template for parameterized, composable SQL | | Operations | createOperation pairs SQL + Zod validator into reusable, context-agnostic query units | | Transactions | db.transact() with automatic commit/rollback | | Schema generation | runSchemaGeneration introspects PostgreSQL and generates Zod validators + TypeScript types | | Adapter contract | PoolLike/PoolClientLike interfaces for integrating any PostgreSQL driver | | Error handling | PiquelError class with typed PiquelErrorCode for programmatic error handling |

Why Piquel?

Piquel is lightweight and versatile, and fits common patterns of database usage. It can easily be integrated into existing projects as it support step by step (even query by query) adoption . Runtime Zod validation in dev and automated tests catches schema drift early while schema generation can be utilized to keep type information in sync with the database.

Documentation

Documentation is available in the docs/ folder:

Examples

Examples are in examples/ and they provide a quick demonstration of most common use cases.