{"id":44076,"library":"tydet-core-mysql","title":"TyDeT Core MySQL","description":"A TypeScript & JavaScript library for TyDeT Core that provides MySQL database connectivity, entity management, validation, and migration tools. Version 2.0.3 is current and actively maintained. It integrates with TyDeT Core as a service, offering a declarative schema definition for entities, relationship management (hasMany/belongsTo), and query building via helper functions like QueryFind. Differentiates from other ORMs by tight coupling with the TyDeT ecosystem and a focus on developer tooling for TypeScript projects.","status":"active","version":"2.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/Kabany/tydet-core-mysql","tags":["javascript","typescript","tydet","tydet core","mysql"],"install":[{"cmd":"npm install tydet-core-mysql","lang":"bash","label":"npm"},{"cmd":"yarn add tydet-core-mysql","lang":"bash","label":"yarn"},{"cmd":"pnpm add tydet-core-mysql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library required for Context, service mounting, and entity framework.","package":"tydet-core","optional":false},{"reason":"MySQL driver for Node.js.","package":"mysql2","optional":false}],"imports":[{"note":"Package is ESM-only. Default export not available.","wrong":"const { MysqlConnector } = require('tydet-core-mysql')","symbol":"MysqlConnector","correct":"import { MysqlConnector } from 'tydet-core-mysql'"},{"note":"Named export specific to MySQL entities. Do not confuse with tydet-core's Entity.","wrong":"import { Entity } from 'tydet-core-mysql'","symbol":"MysqlEntity","correct":"import { MysqlEntity } from 'tydet-core-mysql'"},{"note":"Query helpers are exported from tydet-core-mysql, not tydet-core.","wrong":"import { QueryFind } from 'tydet-core'","symbol":"QueryFind","correct":"import { QueryFind } from 'tydet-core-mysql'"},{"note":"Exported as MysqlDataType; namespace-like object for MySQL column types.","wrong":"import { DataType } from 'tydet-core-mysql'","symbol":"MysqlDataType","correct":"import { MysqlDataType } from 'tydet-core-mysql'"},{"note":"Exported as MysqlDefaultValue; provides constants like NOW for default values.","wrong":"import { DefaultValue } from 'tydet-core-mysql'","symbol":"MysqlDefaultValue","correct":"import { MysqlDefaultValue } from 'tydet-core-mysql'"}],"quickstart":{"code":"import { Context } from 'tydet-core';\nimport { MysqlConnector, MysqlEntity, QueryFind, MysqlDataType, MysqlDefaultValue } from 'tydet-core-mysql';\n\nconst app = new Context();\nconst mysql = new MysqlConnector({ host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test' });\nawait app.mountService('mysql', mysql);\n\nconst query = QueryFind(mysql, 'users', { firstName: 'John' });\nconst data = await mysql.run(query);\n\nclass User extends MysqlEntity {\n  id: number;\n  firstName: string;\n  lastName: string;\n}\n\nUser.DefineSchema('users', {\n  id: { type: MysqlDataType.INT, primaryKey: true },\n  firstName: { type: MysqlDataType.VARCHAR, required: true },\n  lastName: MysqlDataType.VARCHAR\n});\n\nconst users = await User.Find(mysql, { firstName: 'John' });","lang":"typescript","description":"Initializes a TyDeT Core context, mounts a MySQL connector as a service, defines an entity with schema, and runs a find query."},"warnings":[{"fix":"Provide connection config object with host, user, password, and database properties when constructing MysqlConnector.","message":"MysqlConnector constructor options changed: in v2.x, host and user are required; previously they were optional with defaults.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use User.Find(mysql, condition) instead of QueryFind(mysql, table, condition).","message":"The method 'QueryFind' is deprecated in favor of 'Entity.Find' static method.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use ES module import syntax. Update your tsconfig to use 'module': 'ESNext' or equivalent. If you must use require, upgrade to Node.js 22 with --experimental-require-module or use dynamic import().","message":"ESM-only: package no longer supports CommonJS require().","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure property names in schema objects are exactly as defined; e.g., 'type', 'primaryKey', 'required', 'default'.","message":"Schema column definitions must use uppercase property names for type, primaryKey, etc. (matching TypeScript interfaces).","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'2.0.3':23 'activ':27 'build':49 'connect':15 'core':2,10,33,79 'coupl':61 'current':25 'databas':14 'declar':39 'definit':41 'develop':70 'differenti':55 'ecosystem':65 'entiti':16,43 'focus':68 'function':52 'hasmany/belongsto':46 'helper':51 'integr':30 'javascript':6,75 'librari':7 'like':53 'maintain':28 'manag':17,45 'migrat':20 'mysql':3,13,80 'offer':37 'orm':58 'project':74 'provid':12 'queri':48 'queryfind':54 'relationship':44 'schema':40 'servic':36 'tight':60 'tool':21,71 'tydet':1,9,32,64,77,78 'typescript':5,73,76 'valid':18 'version':22 'via':50","created_at":"2026-06-05T17:02:51.594269+00:00","updated_at":"2026-06-05T17:02:51.594269+00:00","problems":[{"fix":"new MysqlConnector({ host: 'localhost', user: 'root', password: '...', database: '...' })","cause":"MysqlConnector instantiated without a connection config object.","error":"TypeError: Cannot destructure property 'host' of 'undefined' or 'null'."},{"fix":"Use import statements. If necessary, use dynamic import: const { MysqlConnector } = await import('tydet-core-mysql');","cause":"Trying to use CJS require() with an ESM-only package.","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Ensure class extends MysqlEntity and call User.DefineSchema() before using static methods.","cause":"Entity classes not extending MysqlEntity correctly or missing DefineSchema call.","error":"Cannot read property 'prototype' of undefined"}],"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/Kabany/tydet-core-mysql#readme","github":"https://github.com/Kabany/tydet-core-mysql","docs":null,"changelog":null,"pypi":null,"npm":"tydet-core-mysql","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}}