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

easyqlite

v0.1.0

Published

JSON schema to validated SQLite DDL, migrations, and seed data

Readme

easyqlite

JSON schema → validated SQLite DDL. Install in any Node, Bun, or browser project:

npm install easyqlite
import { assertValidSchema, generateSQLite } from "easyqlite";

assertValidSchema(schemaJson);
const ddl = generateSQLite(schemaJson); // SQLite DDL string, no DB I/O

The library entry is dependency-free pure functions, so it bundles for browsers unchanged. The easyql CLI binary ships in the same package.

Repo name is easyql; the published npm package is easyqlite (easyql was already taken on npm).

CLI

Usage

bun install
bun run src/index.ts [schema.json] [-o out.sql]   # generate
bun run src/index.ts diff old.json new.json       # migrate
bun run src/index.ts seed schema.json seed.json   # seed data
bun run src/index.ts validate schema.json [seed]  # check, quiet on success
bun run src/index.ts init [dir]                   # scaffold schema.json + seed.json

Installed as a dependency, the easyql bin is available (bunx easyql schema.json).

Migrations

bun run src/index.ts diff old.json new.json [-o migration.sql]

Emits CREATE/DROP TABLE, ADD/DROP COLUMN, and CREATE/DROP INDEX statements. Changes SQLite ALTER TABLE can't express (altered columns, added primary keys, FK changes on existing columns, dropping PK/UNIQUE/ indexed/FK-targeted columns) rebuild the table instead: RENAME → CREATE → copy shared columns → DROP → recreate indexes, wrapped in PRAGMA foreign_keys=OFF/ON. Rebuilding a parent also rebuilds tables that reference it. Added foreign keys on new columns ride along inline via ADD COLUMN ... REFERENCES ....

Seed data (seed.json)

bun run src/index.ts seed schema.json seed.json [-o seed.sql]
{
  "users": [{ "id": "u1", "name": "Ada" }],
  "posts": [{ "id": "p1", "user_id": "u1" }]
}

Rows are type-checked against the schema (missing NOT NULL columns without defaults, wrong types, null into NOT NULL, blob columns all rejected) and foreign keys must resolve within the seed file — seeds are self-contained. Output is parent-first multi-row INSERTs.

Programmatic use

import { assertValidSchema, generateSQLite } from "easyqlite";

assertValidSchema(schemaJson);
const ddl = generateSQLite(schemaJson);

Schema shape (schema.json)

{
  "users": {
    "columns": [
      { "c_name": "id", "c_type": "text", "is_primary_key": true },
      { "c_name": "email", "c_type": "text", "is_nullable": false, "is_unique": true },
      { "c_name": "nick", "c_type": "text", "default": "anon" }
    ]
  },
  "posts": {
    "columns": [
      { "c_name": "id", "c_type": "text", "is_primary_key": true },
      { "c_name": "user_id", "c_type": "text", "is_nullable": false }
    ],
    "relations": [
      {
        "type": "many_to_one",
        "column": "user_id",
        "references": { "table": "users", "column": "id" },
        "on_delete": "cascade"
      }
    ]
  }
}
  • c_type: text | integer | real | blob | numeric
  • is_nullable defaults to true; primary keys are always NOT NULL
  • default: string or number literal
  • relations: many_to_one only; on_delete: cascade | set null | set default | restrict | no action
  • indexes: { columns, unique?, name? } → emitted as CREATE [UNIQUE] INDEX after all tables; default name idx_<table>_<cols> (composite columns = composite UNIQUE)

The validator rejects unknown table/column references, bad types, nullable primary keys, and bad on_delete values before any SQL is generated.

Notes

  • Output is DDL only. At runtime, enable PRAGMA foreign_keys = ON or foreign keys won't be enforced by SQLite.
  • Tables are emitted dependency-first; circular FK dependencies are an error.

Dev

bunx tsc --noEmit   # typecheck
bunx vitest run     # tests (incl. executing generated DDL on real SQLite)

Releases

Push a tag (git tag v0.1.0 && git push origin v0.1.0) — CI verifies, compiles a standalone binary per OS via bun build --compile, and attaches them to the GitHub release. The npm package stays private; binaries are the distribution.