{"id":26429,"library":"sqlqueryhelperjs","title":"SQLQueryHelperjs","description":"Runtime database evolution engine for SQL systems (SQLite, PostgreSQL, MySQL) that lets you define schemas in code, reflect existing databases, and synchronize structure automatically. Version 1.2.6 (stable, active development) combines ORM-like schema definitions, automatic migration-less evolution, fluent SQL builder with joins/CTEs/window functions, and legacy DB inspection into one package. Unlike typical ORMs, it preserves full SQL control while handling schema changes safely. Ships TypeScript types and supports both ESM and CommonJS.","status":"active","version":"1.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/jgabocc/SQLQueryHelperJs","tags":["javascript","sql","database","orm","query-builder","typescript"],"install":[{"cmd":"npm install sqlqueryhelperjs","lang":"bash","label":"npm"},{"cmd":"yarn add sqlqueryhelperjs","lang":"bash","label":"yarn"},{"cmd":"pnpm add sqlqueryhelperjs","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for SQLite runtime engine","package":"better-sqlite3","optional":true},{"reason":"Required for MySQL runtime engine","package":"mysql2","optional":true},{"reason":"Required for PostgreSQL runtime engine","package":"pg","optional":true}],"imports":[{"note":"Works with both ESM import and CJS require. The correct import in ESM is the named import shown.","wrong":"const { SqliteReflector } = require('sqlqueryhelperjs')","symbol":"SqliteReflector","correct":"import { SqliteReflector } from 'sqlqueryhelperjs'"},{"note":"column is a named export, not default. Do not use default import.","wrong":"import column from 'sqlqueryhelperjs'","symbol":"column","correct":"import { column } from 'sqlqueryhelperjs'"},{"note":"Value export used to define entity metadata on a class.","symbol":"entity","correct":"import { entity } from 'sqlqueryhelperjs'"},{"note":"Function to define primary keys with options like autoIncrement.","symbol":"primaryKey","correct":"import { primaryKey } from 'sqlqueryhelperjs'"},{"note":"For PostgreSQL engine. Requires 'pg' package.","symbol":"PostgresReflector","correct":"import { PostgresReflector } from 'sqlqueryhelperjs'"},{"note":"For MySQL engine. Requires 'mysql2' package.","symbol":"MysqlReflector","correct":"import { MysqlReflector } from 'sqlqueryhelperjs'"}],"quickstart":{"code":"import { SqliteReflector, column, entity, primaryKey } from 'sqlqueryhelperjs';\n\nclass User {\n  static entity = entity({\n    table: 'users',\n    columns: {\n      id: column.integer(),\n      email: column.text({ nullable: false }),\n    },\n    primaryKey: primaryKey('id', { autoIncrement: true }),\n  });\n}\n\nconst db = new SqliteReflector({ filename: process.env.DB_PATH ?? 'app.db' });\ndb.reflect(User);\n\nconst rows = db.select(['id', 'email']).from('users').all();\nconsole.log(rows);","lang":"typescript","description":"Defines a User entity with auto-incrementing id and non-null email, reflects it to synchronize the database, then queries all rows."},"warnings":[{"fix":"Use db.planReflect() to preview changes and set confirmDestructive: true in engine options to require explicit approval.","message":"Schema synchronization may ALTER or DROP columns. Always review destructive changes before applying in production.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Define 'static entity = entity({...})' on every class passed to db.reflect().","message":"Entity class must have static 'entity' property. Forgetting it will result in runtime error.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Replace 'class User extends Entity { ... }' with 'class User { static entity = entity({...}) }'","message":"Legacy entity definition using 'Entity' base class is deprecated. Use static entity property instead.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure you use the appropriate module system consistently: ESM with import and CJS with require.","message":"ESM and CJS modules are bundled; however, using require() in an ESM project may cause issues.","severity":"gotcha","affected_versions":">=1.2.0"},{"fix":"Migrate from .output() to .returning() when using MySQL reflector.","message":"MySQL engine now includes returning() support for DML; old code using 'output' may break.","severity":"breaking","affected_versions":">=1.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure class has a static entity property defined with entity({...}) and call db.reflect(YourClass).","cause":"Missing static entity property on class or class not passed to reflect().","error":"Error: No engine loaded. Did you call .reflect(...) with an entity class?"},{"fix":"Add 'static entity = entity({...})' to the class definition.","cause":"Entity class does not have a static 'entity' property, or the class is undefined.","error":"TypeError: Cannot read properties of undefined (reading 'entity')"},{"fix":"Set NODE_OPTIONS=--openssl-legacy-provider environment variable.","cause":"OpenSSL version mismatch in Node.js 17+ when using legacy crypto.","error":"error:0308010C:digital envelope routines::unsupported"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}