Minimal ORM for MySQL, PostgreSQL, and SQLite with full arbitrary SQL query support. Version 4.0.5 is the latest stable release. It is built on the node-sql query builder and node-anydb connection pool. Unlike heavier ORMs like Sequelize or TypeORM, it provides a thin layer over SQL, allowing direct SQL while adding table definitions, relationship-based joins, and deep result selection (selectDeep). It ships TypeScript types and supports both callback and promise patterns. Release cadence is low, with updates primarily addressing bug fixes.
npm install anydb-sql-2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes a database connection, defines two tables with a relationship, performs a join query, and uses selectDeep to get nested results.
If using ESM, use import anydbsql from 'anydb-sql-2'. If using CommonJS, use const anydbsql = require('anydb-sql-2') without .default.Use promise-based API: e.g., .all() returns a Promise.
Always define the has property on table definitions when using selectDeep with relationships.
Use db.begin() to get a transaction object, then pass it to the Within methods.
Ensure the sql package version is compatible. Check anydb-sql-2's package.json for peerDependencies.
Use import anydbsql from 'anydb-sql-2' (ESM) or const anydbsql = require('anydb-sql-2') (CJS without .default)npm install sql
Update anydb-sql-2 to latest version; ensure TypeScript types are installed (the package ships types). If issue persists, use // @ts-ignore.
Provide a callback or use promise chain (e.g., .all().then(...))