{"id":43341,"library":"mysql-records","title":"mysql-records","description":"A simple MySQL ORM library providing basic model, link, and primary key support. Currently at version 0.5.11, it is in early development with incomplete documentation and no tests. It targets Node.js and requires a MySQL connection. Not suitable for production use due to its unstable API and lack of features like migrations or query grouping.","status":"maintenance","version":"0.5.11","language":"javascript","source_language":"en","source_url":"https://github.com/yhaskell/mysql-records","tags":["javascript","typescript"],"install":[{"cmd":"npm install mysql-records","lang":"bash","label":"npm"},{"cmd":"yarn add mysql-records","lang":"bash","label":"yarn"},{"cmd":"pnpm add mysql-records","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for MySQL database connection and queries","package":"mysql","optional":false}],"imports":[{"note":"Package does not export a default CommonJS object; use ESM import.","wrong":"const mysqlRecords = require('mysql-records')","symbol":"mysqlRecords","correct":"import mysqlRecords from 'mysql-records'"},{"note":"Model is a named export, not a default export.","wrong":"import Model from 'mysql-records'","symbol":"Model","correct":"import { Model } from 'mysql-records'"},{"note":"MySQLConnection is only a type and should be imported as a type.","wrong":"import { MySQLConnection } from 'mysql-records'","symbol":"MySQLConnection","correct":"import type { MySQLConnection } from 'mysql-records'"}],"quickstart":{"code":"import mysqlRecords from 'mysql-records';\nimport mysql from 'mysql';\n\nconst connection = mysql.createConnection({\n  host: process.env.MYSQL_HOST ?? 'localhost',\n  user: process.env.MYSQL_USER ?? 'root',\n  password: process.env.MYSQL_PASSWORD ?? '',\n  database: process.env.MYSQL_DB ?? 'test'\n});\n\nconst { Model } = mysqlRecords(connection);\n\nclass User extends Model {\n  static get tableName() {\n    return 'users';\n  }\n}\n\nasync function main() {\n  await connection.connect();\n  const users = await User.find({});\n  console.log('Users:', users);\n  await connection.end();\n}\n\nmain().catch(console.error);","lang":"typescript","description":"This example demonstrates connecting to a MySQL database and creating a simple model class to query all users."},"warnings":[{"fix":"Pin to a specific version and test thoroughly before upgrading.","message":"Package is in early development (0.x) with no tests, incomplete documentation, and unstable API. Breaking changes are expected.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always pass a valid mysql connection object to mysqlRecords().","message":"MySQL connection must be provided explicitly; otherwise, the library throws.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Avoid relying on any internal properties; use exposed Model methods.","message":"The library uses undocumented internal keys (e.g., __db__) that may change without notice.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use async/await or Promises: await Model.find({}) instead of .do() callbacks.","message":"The old callback-based query style using .do() is deprecated. Use the async/await style with .find() directly.","severity":"deprecated","affected_versions":">=0.3.0"}],"env_vars":null,"search_vec":"'0.5.11':20 'api':49 'basic':10 'connect':39 'current':17 'develop':25 'document':28 'due':45 'earli':24 'featur':53 'group':58 'incomplet':27 'javascript':59 'key':15 'lack':51 'librari':8 'like':54 'link':12 'migrat':55 'model':11 'mysql':2,6,38 'mysql-record':1 'node.js':34 'orm':7 'primari':14 'product':43 'provid':9 'queri':57 'record':3 'requir':36 'simpl':5 'suitabl':41 'support':16 'target':33 'test':31 'typescript':60 'unstabl':48 'use':44 'version':19","created_at":"2026-06-05T16:59:20.278048+00:00","updated_at":"2026-06-05T16:59:20.278048+00:00","problems":[{"fix":"Use ESM import: import mysqlRecords from 'mysql-records'","cause":"Using CommonJS require which doesn't get the default export correctly.","error":"TypeError: mysql_records_1.default is not a function"},{"fix":"Run: npm install mysql","cause":"Missing peer dependency 'mysql'.","error":"Cannot find module 'mysql'"},{"fix":"Use the Model class returned from mysqlRecords(connection), not the one from direct import.","cause":"Attempting to instantiate Model directly without calling mysqlRecords(connection).","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/yhaskell/mysql-records#readme","github":"https://github.com/yhaskell/mysql-records","docs":null,"changelog":null,"pypi":null,"npm":"mysql-records","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}}