{"id":45240,"library":"kp-mysql-models","title":"kp-mysql-models","description":"kp-mysql-models v1.5.1 is a lightweight, promise-based Node.js ORM for MySQL that simplifies CRUD operations, advanced joins, pagination, soft deletes, and relationship handling (hasOne, belongsTo, hasMany). It uses model-based query building with a minimal footprint. Compared to larger ORMs like Sequelize, it offers a simpler, less opinionated API with direct pool connection management. The package is available on npm under both 'kp-mysql-models' and '@krishnapawar/kp-mysql-models' with no significant release cadence documented. It requires Node.js >=12.0.0 and a MySQL connection pool from the 'mysql' package.","status":"active","version":"1.5.1","language":"javascript","source_language":"en","source_url":"https://github.com/krishnapawar/kp-mysql-models","tags":["javascript","kp-mysql-models","@krishnapawar/kp-mysql-models","mysql-models-builder","model","mysql models","mysql","query","builder"],"install":[{"cmd":"npm install kp-mysql-models","lang":"bash","label":"npm"},{"cmd":"yarn add kp-mysql-models","lang":"bash","label":"yarn"},{"cmd":"pnpm add kp-mysql-models","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required to create a MySQL connection pool passed to BaseModels constructor","package":"mysql","optional":false}],"imports":[{"note":"Library is CJS-only; named import from CJS works in bundlers. In Node's native ESM, use createRequire or dynamic import().","wrong":"const BaseModels = require('kp-mysql-models')","symbol":"BaseModels","correct":"import { BaseModels } from 'kp-mysql-models'"},{"note":"Requires destructuring because BaseModels is not a default export.","wrong":"const kp = require('kp-mysql-models')","symbol":"BaseModels","correct":"const { BaseModels } = require('kp-mysql-models')"},{"note":"Both packages are identical; choose one consistently to avoid duplication.","wrong":"require('kp-mysql-models')","symbol":"BaseModels","correct":"const { BaseModels } = require('@krishnapawar/kp-mysql-models')"}],"quickstart":{"code":"const mysql = require('mysql');\nconst { BaseModels } = require('kp-mysql-models');\n\nconst pool = mysql.createPool({\n  connectionLimit: 10,\n  host: process.env.DB_HOST ?? 'localhost',\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASSWORD ?? '',\n  database: process.env.DB_NAME ?? 'test'\n});\n\nclass User extends BaseModels {\n  constructor() {\n    super(pool);\n    this._table = 'users';\n    this._hidden = ['password'];\n  }\n}\n\nconst userModel = new User();\n\nasync function main() {\n  const users = await userModel.get();\n  console.log(users);\n}\nmain().catch(console.error);","lang":"javascript","description":"Shows full setup: create a MySQL pool, define a User model extending BaseModels, and fetch all users with hidden fields."},"warnings":[{"fix":"Always pass a pool created with mysql.createPool().","message":"The library expects a mysql connection pool, not a connection object. Passing a single connection will cause 'Cannot read property 'query' of undefined' or similar errors.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use super(pool) in constructor; avoid setting this._connection manually.","message":"Using this._connection directly in the constructor may be deprecated in future versions. The recommended pattern is to pass the pool via super(pool).","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use CommonJS require() or wrap with createRequire in ESM.","message":"The library does not support native ES modules. Attempting import { BaseModels } from 'kp-mysql-models' in Node.js ESM will fail with ERR_MODULE_NOT_FOUND.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Choose one package name and stick with it; uninstall the other.","message":"The package is also published under @krishnapawar/kp-mysql-models. Installing both variants can cause duplicate registrations and conflicts.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'12.0.0':87 'advanc':24 'api':58 'avail':67 'base':15,39 'belongsto':33 'build':41 'builder':106,112 'cadenc':82 'compar':46 'connect':62,91 'crud':22 'delet':28 'direct':60 'document':83 'footprint':45 'handl':31 'hasmani':34 'hason':32 'javascript':97 'join':25 'kp':2,6,73,99 'kp-mysql-model':1,5,72,98 'krishnapawar/kp-mysql-models':77,102 'larger':48 'less':56 'lightweight':12 'like':50 'manag':63 'minim':44 'model':4,8,38,75,101,105,107,109 'model-bas':37 'mysql':3,7,19,74,90,95,100,104,108,110 'mysql-models-build':103 'node.js':16,86 'npm':69 'offer':53 'oper':23 'opinion':57 'orm':17,49 'packag':65,96 'pagin':26 'pool':61,92 'promis':14 'promise-bas':13 'queri':40,111 'relationship':30 'releas':81 'requir':85 'sequel':51 'signific':80 'simpler':55 'simplifi':21 'soft':27 'use':36 'v1.5.1':9","created_at":"2026-06-07T12:54:03.200691+00:00","updated_at":"2026-06-07T12:54:03.200691+00:00","problems":[{"fix":"Run: npm install kp-mysql-models (or npm install @krishnapawar/kp-mysql-models) and use consistent import.","cause":"Package not installed or installed under different package name (@krishnapawar/kp-mysql-models).","error":"Error: Cannot find module 'kp-mysql-models'"},{"fix":"Use: const { BaseModels } = require('kp-mysql-models');","cause":"BaseModels is a named export, not a default export; using import BaseModels from '...' instead of { BaseModels }.","error":"TypeError: super is not a constructor"},{"fix":"Use mysql.createPool() and pass the pool to super(pool) in the model constructor.","cause":"Pool not passed or passed incorrectly to BaseModels constructor (e.g., passing a connection instead of pool).","error":"Cannot read property 'query' of undefined"},{"fix":"Transform your file to CommonJS (.cjs extension) or use dynamic import: const { BaseModels } = await import('kp-mysql-models');","cause":"Trying to require the package in an ES module context.","error":"ERR_REQUIRE_ESM"}],"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/krishnapawar/kp-mysql-models#readme","github":"https://github.com/krishnapawar/kp-mysql-models","docs":null,"changelog":null,"pypi":null,"npm":"kp-mysql-models","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-07","next_check":"2026-09-05","install_tag":null}}