Registry / database / gg-mysql-connector

gg-mysql-connector

JSON →
library1.0.247jsnpmunverified

gg-mysql-connector (v1.0.247) is a TypeScript-first MySQL toolkit that provides schema definition, migration, TypeScript and Zod artifact generation, and typed querying. It treats schema definitions as a single source of truth, allowing developers to define tables, columns, indexes, and foreign keys in code, then push changes to MySQL. Features include automated migration (table creation, column modification, index updates) and reverse-engineering existing databases to generate types and Zod schemas. Updated frequently with 247+ releases; requires mysql2. Differentiates from Prisma/TypeORM by being lighter-weight and more focused on schema-first workflows without an ORM layer.

npm install gg-mysql-connector
INSTALL
IMPORT
SIG · GG-MYSQL-CONNECTOR
G
gg-mysql-connector
databasejavascriptv1.0.247
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.

GGMySQLConnector
✓ import { GGMySQLConnector } from 'gg-mysql-connector'
✗ const GGMySQLConnector = require('gg-mysql-connector')
ESM-only; no CommonJS module provided.
MySQLSchemaManager
✓ import { MySQLSchemaManager } from 'gg-mysql-connector'
✗ import MySQLSchemaManager from 'gg-mysql-connector'
Named export, not default.
MyModel
✓ import { type MyModel } from 'gg-mysql-connector'
✗ import { MyModel } from 'gg-mysql-connector'
MyModel is a type (Array of ColumnContent), not a class constructor. Use type import to avoid runtime bundle inclusion.
classifyDbError
✓ import { classifyDbError } from 'gg-mysql-connector'
✗ import { classifyDbError as classify } from 'gg-mysql-connector'
Function can be renamed, but no default export.

Connects to MySQL, defines a user table schema, and pushes it to the database using migration manager.

import { GGMySQLConnector, MySQLSchemaManager, MyModel, type DatabaseConfigInterface } from 'gg-mysql-connector'; const dbInfo: DatabaseConfigInterface = { host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'test', port: 3306, dateStrings: true, connectionLimit: 3, waitForConnections: true, connectTimeout: 10000, queueLimit: 0, enableKeepAlive: true, keepAliveInitialDelay: 1000, }; const db = new GGMySQLConnector(dbInfo); const model: MyModel[] = [ { tableName: 'users', columns: [ { COLUMN_NAME: 'id', DATA_TYPE: 'int', AUTO_INCREMENT: true }, { COLUMN_NAME: 'name', DATA_TYPE: 'varchar(255)' }, ], }, ]; const migrator = new MySQLSchemaManager(dbInfo, model); migrator.isShowProgress = true; await migrator.init(); await migrator.pushSchemaToDatabase();
Debug
Known issues
gotchaInvalid numeric pool options (e.g., connectionLimit set to a non-number) silently fall back to defaults; no error thrown.
fix
Ensure all numeric pool options are valid numbers. For connectionLimit, the default is 10 if invalid.
affects: >=1.0.0
gotchaBoolean options (e.g., waitForConnections) are only respected when the value is exactly true or false; other values are ignored.
fix
Always set boolean options to a literal true or false, not a string or number.
affects: >=1.0.0
deprecatedThe pushVie method name is misspelled (should be pushView?); maintained for backward compatibility.
fix
Use pushViews (plural) if available, or accept the typo.
affects: >=1.0.0
gotchaMyModel is a type alias for an array of ColumnContent, not a class. Attempting 'new MyModel()' causes TypeScript compilation error.
fix
Use MyModel as a type annotation for arrays of column definitions, e.g., const model: MyModel[] = [...]
affects: >=1.0.0
gotchaThe generateZodSchemaFromMySQL function requires Zod to be installed as a peer dependency; missing it causes runtime error.
fix
Install zod: npm install zod
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql2'
Missing peer dependency mysql2.
fix
npm install mysql2
TypeError: GGMySQLConnector is not a constructor
Using CommonJS require on an ESM-only package.
fix
Change to import { GGMySQLConnector } from 'gg-mysql-connector' and ensure your project uses ESM (e.g., 'type': 'module' in package.json).
TypeError: MyModel is not a constructor
Trying to instantiate MyModel as a class, but it's a type.
fix
Remove 'new MyModel()' and use MyModel only for type annotations.
Upgrade
Version history
1.0.247latest on npm
Audit
Dependencies
mysql2requiredUnderlying MySQL driver used for all database connections and queries.
zodoptionalRequired for generateZodSchemaFromMySQL utility to produce Zod schemas.
Agent activity
5 hits · last 30 days
node
4
Resources
gg-mysql-connector — npm install gg-mysql-connector · libregistry