{"id":43889,"library":"sql-dao","title":"sql-dao","description":"sql-dao provides an abstract DatabaseAccessObject class for simple CRUD operations, relation management, and validation on SQL databases. Version 1.4.3 (last release) currently supports only MySQL. It is a small, unmaintained library (last update 2017) with a generator to create DAOs from database schemas. Differentiators include automatic relation loading and built-in validation. Not recommended for new projects; consider more modern ORMs like Sequelize or TypeORM.","status":"abandoned","version":"1.4.3","language":"javascript","source_language":"en","source_url":"https://github.com/loge5/node-sql-dao","tags":["javascript","dao","doa","sql","database","access","objects","mysql"],"install":[{"cmd":"npm install sql-dao","lang":"bash","label":"npm"},{"cmd":"yarn add sql-dao","lang":"bash","label":"yarn"},{"cmd":"pnpm add sql-dao","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Only MySQL driver supported; peer dependency for database connection","package":"mysql","optional":false}],"imports":[{"note":"CommonJS; package provides named export. Do not use default import.","wrong":"const DatabaseAccessObject = require('sql-dao')","symbol":"DatabaseAccessObject","correct":"const { DatabaseAccessObject } = require('sql-dao')"},{"note":"WhereClause is exported from the main package, not as separate file.","wrong":"const WhereClause = require('sql-dao/WhereClause')","symbol":"WhereClause","correct":"const { WhereClause } = require('sql-dao')"},{"note":"All relation classes are part of the main export.","wrong":"const RelationBelongsTo = require('sql-dao').RelationBelongsTo","symbol":"RelationBelongsTo","correct":"const { RelationBelongsTo } = require('sql-dao')"}],"quickstart":{"code":"const { DatabaseAccessObject, WhereClause } = require('sql-dao');\n\nclass User extends DatabaseAccessObject {\n  static getMetadata() {\n    return {\n      table: 'users',\n      primaryKey: 'id',\n      columns: { id: { type: 'int' }, name: { type: 'string' } }\n    };\n  }\n}\n\nasync function main() {\n  // Must set database connection globally\n  const mysql = require('mysql');\n  const connection = mysql.createConnection({ host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '' });\n  await connection.connect();\n  // Assume sql-dao uses a global connection; actual usage may vary\n  const user = new User();\n  user.name = 'John';\n  await user.insert();\n  console.log('Inserted user id:', user.id);\n}\n\nmain().catch(console.error);","lang":"javascript","description":"Shows basic usage: extend DatabaseAccessObject, define metadata, insert a record."},"warnings":[{"fix":"Migrate to modern ORM (Sequelize, TypeORM, Prisma) for ongoing support.","message":"Package last updated in 2017; only MySQL supported; no active development.","severity":"deprecated","affected_versions":"*"},{"fix":"Ensure to initialize and pass connection properly per library documentation.","message":"Requires manual setup of database connection; not automatically managed.","severity":"gotcha","affected_versions":"*"},{"fix":"Avoid circular relation definitions; design one-directional associations.","message":"Do not create recursive relations (e.g., both belongsTo and hasOne between same classes).","severity":"gotcha","affected_versions":"*"},{"fix":"Use require() in Node.js; no ES import support.","message":"Package uses CommonJS only; no ESM or TypeScript type definitions.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.4.3':24 '2017':39 'abstract':9 'access':77 'automat':51 'built':56 'built-in':55 'class':11 'consid':64 'creat':44 'crud':14 'current':27 'dao':3,6,45,73 'databas':22,47,76 'databaseaccessobject':10 'differenti':49 'doa':74 'generat':42 'includ':50 'javascript':72 'last':25,37 'librari':36 'like':68 'load':53 'manag':17 'modern':66 'mysql':30,79 'new':62 'object':78 'oper':15 'orm':67 'project':63 'provid':7 'recommend':60 'relat':16,52 'releas':26 'schema':48 'sequel':69 'simpl':13 'small':34 'sql':2,5,21,75 'sql-dao':1,4 'support':28 'typeorm':71 'unmaintain':35 'updat':38 'valid':19,58 'version':23","created_at":"2026-06-05T17:01:58.118477+00:00","updated_at":"2026-06-05T17:01:58.118477+00:00","problems":[{"fix":"npm install sql-dao","cause":"Package not installed or incorrect import path.","error":"Cannot find module 'sql-dao'"},{"fix":"Use const { DatabaseAccessObject } = require('sql-dao')","cause":"Using default import instead of named import.","error":"DatabaseAccessObject is not a constructor"},{"fix":"Use const { RelationBelongsTo } = require('sql-dao')","cause":"Relation classes are exported from main package, but imported incorrectly.","error":"RelationBelongsTo is not defined"},{"fix":"Set connection via package configuration (see docs).","cause":"Did not initialize or pass database connection.","error":"No database connection set"}],"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/loge5/node-sql-dao#readme","github":"https://github.com/loge5/node-sql-dao","docs":null,"changelog":null,"pypi":null,"npm":"sql-dao","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}}