Registry / database / think-model-mysql

think-model-mysql

JSON →
library1.1.7jsnpmunverified

MySQL adapter for ThinkJS 3.x ORM. Version 1.1.7 is stable; low release cadence. Provides MySQL-specific model operations (e.g., query building, transactions) within the ThinkJS framework. Requires think-model v3.x. Differentiator: native integration with ThinkJS, leveraging its adapter system.

npm install think-model-mysql
INSTALL
IMPORT
SIG · THINK-MODEL-MYSQL
T
think-model-mysql
databasejavascriptv1.1.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

thinkModelMysql
const thinkModelMysql = require('think-model-mysql');
import thinkModelMysql from 'think-model-mysql';
CommonJS only; this package does not export ESM.
MySQLAdapter
const MySQLAdapter = require('think-model-mysql').MySQLAdapter;
const { MySQLAdapter } = require('think-model-mysql');
Exported as property of module.exports, not destructured.

Show how to require think-model-mysql, get MySQLAdapter, and configure it with ThinkJS model.

const thinkModelMysql = require('think-model-mysql'); const MySQLAdapter = thinkModelMysql.MySQLAdapter; // Configure ThinkJS model with MySQL adapter const model = require('think-model'); const mysqlConfig = { handle: MySQLAdapter, database: 'test', prefix: 'think_', encoding: 'utf8mb4' }; // Register with ThinkJS think.app.use(model(mysqlConfig)); // Then use think.model('user') etc.
Debug
Known issues
gotchaAlways use require(), not import; the package does not support ESM.
fix
Use const thinkModelMysql = require('think-model-mysql');
affects: all
gotchaMySQLAdapter is not directly exported as a named export; it is a property of the default export.
fix
Access MySQLAdapter via require('think-model-mysql').MySQLAdapter
affects: all
deprecatedPackage may be unmaintained; last release was a while ago.
fix
Consider using an alternative ORM like Sequelize or TypeORM with ThinkJS integration.
affects: all
Errors
Common errors & fixes
Cannot find module 'think-model-mysql'
Package not installed or missing from node_modules.
fix
Run npm install think-model-mysql --save
TypeError: thinkModelMysql is not a constructor
Importing the package incorrectly (e.g., using import instead of require).
fix
Use const thinkModelMysql = require('think-model-mysql');
Cannot read property 'MySQLAdapter' of undefined
Attempting to destructure MySQLAdapter from require result incorrectly.
fix
Use const MySQLAdapter = require('think-model-mysql').MySQLAdapter;
Upgrade
Version history
1.1.7latest on npm
Audit
Dependencies
think-modelrequiredPeer dependency; provides base model class and ORM interface
Agent activity
17 hits · last 30 days
node
14
Meta
2
OpenAI (training)
1
Resources
think-model-mysql — npm install think-model-mysql · libregistry