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

@edgelite/edgelite

v0.2.0

Published

edgedb meets sqlite

Readme

EdgeLite

npm CI License: MIT

EdgeDB-style developer experience on PGlite — SDL schema, TypeScript query builder, migration CLI. No server, no concurrency, single data directory on disk.

Install

bun add @edgelite/edgelite

5-minute quickstart

1. Write your schema — dbschema/schema.esdl

scalar type NodeKind extending enum<note, file_chunk>;
scalar type NodeStatus extending enum<pending, live, pruned>;

type Node {
  required kind:       NodeKind;
  required status:     NodeStatus { default := 'pending' };
  required content:    str        { default := '' };
  required created_at: int64;
  required updated_at: int64;
}

2. Generate the query builder

bunx edgelite codegen dbschema/schema.esdl
# → generates dbschema/edgelite.ts

3. Create and apply the initial migration

bunx edgelite migration create   # generates dbschema/migrations/00001-*.sql
bunx edgelite migration apply    # applies it to your local PGlite DB

4. Query

import { openDb } from '@edgelite/edgelite';
import e from './dbschema/edgelite.js';

const db = await openDb('./my-db', './dbschema/schema.esdl', { autoMigrate: true });

// Insert
const node = await db.run(e.insert(e.Node, {
  kind: 'note', content: 'hello world',
  created_at: Date.now(), updated_at: Date.now(),
}));

// Select
const notes = await db.run(e.select(e.Node, n => ({
  id: true, content: true, status: true,
  filter: e.op(n.kind, '=', 'note'),
})));

// Update
await db.run(e.update(e.Node, n => ({
  filter: e.op(n.id, '=', node.id),
  set: { status: 'live', updated_at: Date.now() },
})));

// Count
const pending = await db.run(e.count(e.Node, n => ({
  filter: e.op(n.status, '=', 'pending'),
})));

await db.close();

SDL Reference (v1)

Scalar types

| SDL type | Postgres type | | --- | --- | | str | TEXT | | int64 | BIGINT | | bool | BOOLEAN | | json | JSONB | | vector(N) | vector(N) (pgvector) |

Enums

scalar type Status extending enum<pending, live, pruned>;

Enums are enforced at the TypeScript layer only (no DB CHECK constraint). Passing an invalid value to the generated query builder is a compile error.

Properties

type Node {
  required content: str;              # NOT NULL
  source_uri:       str;              # nullable
  required mtime:   int64 { default := 0 };  # with default
}

Links (foreign keys)

type Node {
  parent: Node;  # → parent_id TEXT REFERENCES nodes(id)
}

One level of link traversal is supported in select:

db.run(e.select(e.Node, n => ({
  id: true, content: true,
  parent: { id: true },  // joins nodes table once
  filter: e.op(n.status, '=', 'live'),
})));

Indexes

index fts on (.content);              # full-text search via tsvector
index vec on (.embedding) using ivfflat;  # pgvector approximate NN

Constraints

constraint exclusive on ((.src, .dst, .kind));  # → UNIQUE(src_id, dst_id, kind)

Query Builder Cheatsheet

import e from './dbschema/edgelite.js';

// SELECT
e.select(e.Node, n => ({
  id: true, content: true,
  parent: { id: true },            // link traversal (one level)
  filter: e.op(n.status, '=', 'live'),
  order_by: { expr: n.created_at, dir: 'DESC' },
  limit: 20,
}))

// INSERT
e.insert(e.Node, { kind: 'note', content: 'hello', ... })

// INSERT OR IGNORE (unique constraint)
e.insert(e.Edge, { src: id1, dst: id2, kind: 'derived_from', ... }).unlessConflict()

// UPDATE
e.update(e.Node, n => ({
  filter: e.op(n.id, '=', id),
  set: { status: 'pruned', updated_at: Date.now() },
}))

// COUNT
e.count(e.Node, n => ({ filter: e.op(n.status, '=', 'pending') }))

// FILTER HELPERS
e.all(e.op(n.status, '=', 'live'), e.op(n.kind, '=', 'note'))  // AND
e.any(e.op(n.status, '=', 'stale'), e.op(n.status, '=', 'pruned'))  // OR

// NEIGHBORS (bidirectional edge traversal)
e.neighbors(nodeId, { edgeKinds: ['derived_from', 'references'] })

// FULL-TEXT SEARCH
e.fts(e.Node, 'search term')

Migrations

edgelite migration create   # diff schema.esdl vs DB → writes dbschema/migrations/000N-*.sql
edgelite migration apply    # apply pending non-destructive migrations
edgelite migration apply --allow-destructive  # also apply DROP TABLE / DROP COLUMN
edgelite migration status   # list applied vs pending (⚠ warns on DESTRUCTIVE)

Migrations are explicit, numbered .sql files committed to git. migration create never modifies your DB — it only writes a file.

autoMigrate

// Applies committed pending migrations on open (skips DESTRUCTIVE ones)
const db = await openDb('./my-db', './schema.esdl', { autoMigrate: true });

autoMigrate: true is safe for plugins and local tools. It never generates migration files.

Destructive migrations

Migrations that contain DROP TABLE or DROP COLUMN are marked with a -- DESTRUCTIVE header. They are skipped by autoMigrate and plain migration apply. Apply them explicitly after backing up your data directory:

cp -r ./my-db ./my-db-backup
edgelite migration apply --allow-destructive

License

MIT © 2026 Joe Black