{"id":42396,"library":"ali-h-mysql-ts","title":"ali-h-mysql-ts","description":"A lightweight TypeScript-friendly MySQL client for Node.js that provides a fluent API for query construction, inserts, updates, and deletes. Version 1.3.17 (latest) is actively maintained with monthly releases. Unlike raw mysql2 or knex, it offers a chainable builder pattern inspired by LINQ, supports automatic pagination, join, and subquery helpers. Includes TypeScript definitions, ES module and CommonJS support. Targets Node.js 8+.","status":"active","version":"1.3.17","language":"javascript","source_language":"en","source_url":"https://github.com/han88829/ali-mysql-client#feature","tags":["javascript","typescript"],"install":[{"cmd":"npm install ali-h-mysql-ts","lang":"bash","label":"npm"},{"cmd":"yarn add ali-h-mysql-ts","lang":"bash","label":"yarn"},{"cmd":"pnpm add ali-h-mysql-ts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying MySQL driver for all database operations","package":"mysql2","optional":false}],"imports":[{"note":"Package is ali-h-mysql-ts, not ali-mysql-client. Default import works in ESM.","wrong":"const DbClient = require('ali-mysql-client')","symbol":"default","correct":"import DbClient from 'ali-h-mysql-ts'"},{"note":"Works in CommonJS; ESM import also supported.","wrong":"import DbClient from 'ali-h-mysql-ts'","symbol":"default (CJS)","correct":"const DbClient = require('ali-h-mysql-ts')"},{"note":"Named export for SQL literals like now, true, false.","wrong":"const literals = require('ali-mysql-client').literals","symbol":"literals","correct":"import { literals } from 'ali-h-mysql-ts'"}],"quickstart":{"code":"import DbClient from 'ali-h-mysql-ts';\n\nconst db = new DbClient({\n  host: process.env.DB_HOST ?? 'localhost',\n  port: Number(process.env.DB_PORT ?? 3306),\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASSWORD ?? '',\n  database: process.env.DB_NAME ?? 'test',\n  dateStrings: true,\n  timezone: '+08:00'\n});\n\nasync function main() {\n  // Create table\n  await db.raw(`CREATE TABLE IF NOT EXISTS users (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    name VARCHAR(255) NOT NULL,\n    email VARCHAR(255)\n  )`);\n\n  // Insert\n  const insertResult = await db\n    .insert('users', { name: 'Alice', email: 'alice@example.com' })\n    .execute();\n  console.log('Insert ID:', insertResult.insertId);\n\n  // Select\n  const user = await db\n    .select('*')\n    .from('users')\n    .where('id', insertResult.insertId)\n    .findOne();\n  console.log('Found user:', user);\n\n  // Update\n  await db\n    .update('users')\n    .set('email', 'alice@newdomain.com')\n    .where('id', insertResult.insertId)\n    .execute();\n\n  // Delete\n  await db\n    .delete('users')\n    .where('id', insertResult.insertId)\n    .execute();\n}\nmain().catch(console.error);","lang":"typescript","description":"Demonstrates basic CRUD operations: insert, select (findOne), update, and delete using the fluent builder pattern."},"warnings":[{"fix":"Use require('ali-h-mysql-ts') or import from 'ali-h-mysql-ts'","message":"Package name ali-h-mysql-ts vs common mistake ali-mysql-client","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Run npm install mysql2 alongside ali-h-mysql-ts","message":"mysql2 is required as a peer dependency, not bundled","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use the builder API instead of raw SQL where possible","message":"Raw queries using db.raw() are not chainable and may be deprecated in future","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Set timezone to '+00:00' for UTC or the appropriate offset","message":"Timezone option affects date strings; 'Z' offset may cause confusion","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use CommonJS require() or upgrade Node.js to 12+","message":"ESM import may fail in older Node versions (<12) without --experimental-modules","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Explicitly set column values or omit them","message":"Null values in insert/update are treated as SQL NULL, not string 'null'","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use import { literals } from 'ali-h-mysql-ts' instead of db.literals","message":"DbClient.literals is a static getter; destructuring literals from the instance may break","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.3.17':28 '8':67 'activ':31 'ali':2 'ali-h-mysql-t':1 'api':19 'automat':51 'builder':45 'chainabl':44 'client':12 'commonj':63 'construct':22 'definit':59 'delet':26 'es':60 'fluent':18 'friend':10 'h':3 'helper':56 'includ':57 'insert':23 'inspir':47 'javascript':68 'join':53 'knex':40 'latest':29 'lightweight':7 'linq':49 'maintain':32 'modul':61 'month':34 'mysql':4,11 'mysql2':38 'node.js':14,66 'offer':42 'pagin':52 'pattern':46 'provid':16 'queri':21 'raw':37 'releas':35 'subqueri':55 'support':50,64 'target':65 'ts':5 'typescript':9,58,69 'typescript-friend':8 'unlik':36 'updat':24 'version':27","created_at":"2026-06-05T16:54:46.835387+00:00","updated_at":"2026-06-05T16:54:46.835387+00:00","problems":[{"fix":"Install ali-h-mysql-ts (npm install ali-h-mysql-ts) and update require/import","cause":"Using old package name instead of 'ali-h-mysql-ts'","error":"Cannot find module 'ali-mysql-client'"},{"fix":"Run npm install mysql2","cause":"mysql2 peer dependency not installed","error":"Error: Cannot find module 'mysql2'"},{"fix":"Ensure you use the builder: db.select('*').from('table')...","cause":"Calling .from() on a non-chained object, possibly using raw() incorrectly","error":"TypeError: db.select(...).from is not a function"},{"fix":"Use .insert() with .onDuplicateKeyUpdate() or check existence first","cause":"Inserting a row with an existing primary key value","error":"Duplicate entry '...' for key 'PRIMARY'"}],"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/han88829/ali-mysql-client/tree/feature#readme","github":"https://github.com/han88829/ali-mysql-client#feature","docs":null,"changelog":null,"pypi":null,"npm":"ali-h-mysql-ts","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}}