{"id":43838,"library":"simple-sql-model","title":"Simple SQL Model","description":"A lightweight, Rails-style model wrapper around the `sql` library for Node.js. Version 0.9.4 provides CRUD operations, query methods (findOne, findMany, count), hooks (before/after create/update/destroy), and foreign key reference expansion. It relies on ES6+ features (async/await, classes) and requires Node >=4.8.1. The package is explicitly marked as unstable and not recommended for production use. It is database-agnostic, supporting any SQL dialect that the `sql` module supports (e.g., PostgreSQL, MySQL). Release cadence is irregular; the last commit was in 2019.","status":"active","version":"0.9.4","language":"javascript","source_language":"en","source_url":"https://github.com/danawoodman/simple-sql-model","tags":["javascript","sql","model","class","util","orm","postgres","postgresql","mysql"],"install":[{"cmd":"npm install simple-sql-model","lang":"bash","label":"npm"},{"cmd":"yarn add simple-sql-model","lang":"bash","label":"yarn"},{"cmd":"pnpm add simple-sql-model","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency providing SQL dialect support and query building.","package":"sql","optional":false}],"imports":[{"note":"Package uses CommonJS, not ESM. No default export; module.exports = Model class.","wrong":"import Model from 'simple-sql-model'","symbol":"Model","correct":"const Model = require('simple-sql-model')"},{"note":"For TypeScript or ESM environments, use `import Model = require('simple-sql-model')` or `const Model = require('simple-sql-model')`. No named exports.","wrong":null,"symbol":"Model (with ES6 import)","correct":"import Model = require('simple-sql-model')"},{"note":"configure() takes an object with required `connection`, `table`, `columns` and optional `references`. Works on subclasses as static method.","wrong":"Model.configure({ connection: conn, table: 'users', columns: ['id', 'name'], references: { ... } })","symbol":"Model.configure","correct":"const Model = require('simple-sql-model')\nModel.configure({ connection, table, columns })"}],"quickstart":{"code":"const pgp = require('pg-promise')()\nconst Connection = require('pg-promise')\nconst Model = require('simple-sql-model')\n\nconst connection = Connection({\n  database: process.env.DB_NAME ?? 'test',\n  user: process.env.DB_USER ?? 'test',\n  password: process.env.DB_PASS ?? '',\n  host: process.env.DB_HOST ?? 'localhost',\n  port: Number(process.env.DB_PORT ?? 5432),\n})\n\nclass User extends Model {}\n\nUser.configure({\n  connection,\n  table: 'users',\n  columns: ['id', 'name', 'email'],\n})\n\nasync function run() {\n  await User.create({ name: 'Alice', email: 'alice@example.com' })\n  const user = await User.findOne(1)\n  console.log(user)\n}\n\nrun().catch(console.error)","lang":"javascript","description":"Quickstart: connect to PostgreSQL, define a User model with columns, create a record and query by ID."},"warnings":[{"fix":"Use a more mature ORM like Sequelize, Knex.js, or TypeORM for production applications.","message":"Package is considered unstable and not recommended for production use as per README.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use Node 7.8+ or transpile with Babel.","message":"Requires Node >=4.8.1 and ES6 features (async/await, classes). Older Node versions will not work.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Ensure your database library's connection object has a `query` method returning a Promise. For pg-promise, use `pgp()`; for mysql, use a promise wrapper.","message":"Dependency on the `sql` module; the returned connection must provide a Promise-returning `query` method. Not all database adapters are compatible.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider migrating to actively maintained alternatives.","message":"No updates since 2019; the package may be effectively abandoned. Last commit was over 4 years ago.","severity":"deprecated","affected_versions":">0.9.4"}],"env_vars":null,"search_vec":"'0.9.4':18 '2019':85 '4.8.1':45 'agnost':63 'around':11 'async/await':40 'before/after':28 'cadenc':77 'class':41,89 'commit':82 'count':26 'create/update/destroy':29 'crud':20 'databas':62 'database-agnost':61 'dialect':67 'e.g':73 'es6':38 'expans':34 'explicit':49 'featur':39 'findmani':25 'findon':24 'foreign':31 'hook':27 'irregular':79 'javascript':86 'key':32 'last':81 'librari':14 'lightweight':5 'mark':50 'method':23 'model':3,9,88 'modul':71 'mysql':75,94 'node':44 'node.js':16 'oper':21 'orm':91 'packag':47 'postgr':92 'postgresql':74,93 'product':57 'provid':19 'queri':22 'rail':7 'rails-styl':6 'recommend':55 'refer':33 'releas':76 'reli':36 'requir':43 'simpl':1 'sql':2,13,66,70,87 'style':8 'support':64,72 'unstabl':52 'use':58 'util':90 'version':17 'wrapper':10","created_at":"2026-06-05T17:01:42.935032+00:00","updated_at":"2026-06-05T17:01:42.935032+00:00","problems":[{"fix":"npm install sql","cause":"Missing peer dependency `sql`.","error":"Cannot find module 'sql'"},{"fix":"Use a compatible database library such as `pg-promise` or `mysql2/promise`.","cause":"The provided connection object does not have a Promise-returning `query` method.","error":"connection.query is not a function"},{"fix":"Use CommonJS require: `const Model = require('simple-sql-model')`","cause":"Using ES module import syntax incorrectly (e.g., `import Model from 'simple-sql-model'`).","error":"Model is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/danawoodman/simple-sql-model#readme","github":"https://github.com/danawoodman/simple-sql-model","docs":null,"changelog":null,"pypi":null,"npm":"simple-sql-model","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}