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

sqlqueryhelperjs

v1.2.6

Published

Runtime database evolution engine for SQL systems

Readme

npm

SQLQueryHelperjs

Control how your database evolves — without losing SQL control.

SQLQueryHelperjs is a runtime database evolution engine for SQL systems.

It allows you to define your schema in code, reflect it at runtime, and safely synchronize database structure — while still writing real SQL.

The published package supports both ESM import and CommonJS require(...) consumers.


🚀 What makes it different?

SQLQueryHelperjs combines capabilities that are usually split across multiple tools:

  • Schema definition (like ORMs)
  • Schema evolution (like migration tools)
  • Full SQL query control (like query builders)
  • Reverse engineering of existing databases

All in a single system.

No migrations. No schema drift. Full control.


✨ Core Features

  • Code-first schema (classes → tables)
  • Runtime schema reflection (db.reflect(...))
  • Automatic schema synchronization
  • Safe schema evolution (ALTER or rebuild with data preservation)
  • Fluent SQL builder (joins, CTEs, subqueries, window functions)
  • Built-in validation to prevent invalid SQL
  • Legacy database inspection (generate classes from existing DB)
  • Entity-aware query helpers
  • Runtime engines for SQLite, PostgreSQL, and MySQL

🔄 How it works

  1. Define your schema using classes
  2. Call db.reflect(...)
  3. The system inspects your database
  4. Applies safe schema updates
  5. Query your data using fluent SQL

🚀 Quick Start

import { SqliteReflector, column, entity, primaryKey } from "sqlqueryhelperjs";

class User {
  static entity = entity({
    table: "users",
    columns: {
      id: column.integer(),
      email: column.text({ nullable: false }),
    },
    primaryKey: primaryKey("id", { autoIncrement: true }),
  });
}

const db = new SqliteReflector({ filename: "app.db" });

db.reflect(User);

const rows = db.select(["id", "email"]).from("users").all();

CommonJS usage is also supported:

const { SqliteReflector, column, entity, primaryKey } = require("sqlqueryhelperjs");

🧭 Legacy Database Support

Already have a database?

You can inspect it and generate entity classes automatically:

sqlh inspect SQLITE "./legacy.db" "./generated/entities.ts"

🧩 Fluent SQL Builder

Supports:

  • joins, subqueries, CTEs
  • window functions
  • set operations (union, intersect, except)
  • aggregation
  • pagination

🛡️ Safety by default

  • prevents invalid SQL chains
  • blocks unsafe multi-statements
  • requires approval for destructive schema changes
  • supports audit logging and change tracking

🎯 Use Cases

  • Local-first applications
  • Internal tools with evolving schemas
  • Rapid prototyping without migrations
  • Systems requiring SQL-level control

🐘 Engine Overview

Current implemented runtimes:

  • SQLite
  • PostgreSQL
  • MySQL

Advanced engine features include:

  • runtime schema planning (planReflect)
  • controlled destructive changes
  • schema inspection and entity generation
  • views, triggers, and stored routines
  • dependency-aware rebuild safety

PostgreSQL remains the most advanced engine for orchestration and governance features.

MySQL now includes query builder, returning(...) for DML, reflect/sync, dependency orchestration, schema change history, audit hooks, routines, triggers, views, and live-tested runtime support.

Benchmark snapshots for SQLite, PostgreSQL, and MySQL are now tracked in the benchmark guide and summarized in the engine matrix.

👉 See full details in DATABASE_ENGINE.md

👉 See benchmark details in docs/benchmarks.md


📚 HTML Documentation

The repository includes a searchable static HTML documentation site powered by TypeDoc.

Read the published documentation at:

👉 https://jgabocc.github.io/SQLQueryHelperJs/

Generate it locally with:

npm run docs

The generated site is written to docs-site/.

If you want the site to rebuild while you document the public API, use:

npm run docs:watch

The docs combine guide pages from docs/ with generated API reference from src/index.ts, so the function and type search stays aligned with the real exported surface.

The editorial guides are separated by engine:

  • SQLite
  • PostgreSQL
  • MySQL
  • SQL Server

SQLite, PostgreSQL, and MySQL are implemented runtime engines. SQL Server remains a separated documentation track for future support.


🧭 Roadmap

  • ✅ SQLite (production-ready)
  • ✅ PostgreSQL (advanced runtime support)
  • ✅ MySQL (advanced runtime support)
  • 🔜 SQL Server
  • 🔜 Cloud sync / multi-instance control

📦 Installation

npm install sqlqueryhelperjs

📄 License

MIT