MySQL adapter for ThinkJS 3.x using the mysql2 driver. Provides a model layer for MySQL databases within ThinkJS applications. Version 2.0.0 supports mysql2 driver 2.x+. Regularly maintained alongside ThinkJS releases. Key differentiator: integrates seamlessly with ThinkJS ORM and provides promise-based API.
npm install think-model-mysql2No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a model class extending MysqlModel and perform a simple query.
Ensure your project uses ThinkJS 3.x.
Update connection options to match mysql2 v2.x specs (e.g., 'connectionLimit' becomes 'pool').
Replace .then() chains with async/await syntax.
Use a single model instance per database connection, e.g. through dependency injection or a factory.
Access 'MysqlModel' as a property of the default export: const MysqlModel = require('think-model-mysql2').MysqlModel;Run 'npm install think-model-mysql2' in your project directory.
Use const MysqlModel = require('think-model-mysql2').MysqlModel; then new MysqlModel(...);Check DB_HOST, DB_USER, DB_PASSWORD, DB_NAME environment variables or connection config.
Start MySQL service or ensure host/port are correct.
Create the database: CREATE DATABASE IF NOT EXISTS test;