Registry / database / tydet-core-mysql

tydet-core-mysql

JSON →
library2.0.3jsnpmunverified

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.

npm install tydet-core-mysql
INSTALL
IMPORT
SIG · TYDET-CORE-MYSQL
T
tydet-core-mysql
databasejavascriptv2.0.3
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.

MysqlConnector
import { MysqlConnector } from 'tydet-core-mysql'
const { MysqlConnector } = require('tydet-core-mysql')
Package is ESM-only. Default export not available.
MysqlEntity
import { MysqlEntity } from 'tydet-core-mysql'
import { Entity } from 'tydet-core-mysql'
Named export specific to MySQL entities. Do not confuse with tydet-core's Entity.
QueryFind
import { QueryFind } from 'tydet-core-mysql'
import { QueryFind } from 'tydet-core'
Query helpers are exported from tydet-core-mysql, not tydet-core.
MysqlDataType
import { MysqlDataType } from 'tydet-core-mysql'
import { DataType } from 'tydet-core-mysql'
Exported as MysqlDataType; namespace-like object for MySQL column types.
MysqlDefaultValue
import { MysqlDefaultValue } from 'tydet-core-mysql'
import { DefaultValue } from 'tydet-core-mysql'
Exported as MysqlDefaultValue; provides constants like NOW for default values.

Initializes a TyDeT Core context, mounts a MySQL connector as a service, defines an entity with schema, and runs a find query.

import { Context } from 'tydet-core'; import { MysqlConnector, MysqlEntity, QueryFind, MysqlDataType, MysqlDefaultValue } from 'tydet-core-mysql'; const app = new Context(); const mysql = new MysqlConnector({ host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test' }); await app.mountService('mysql', mysql); const query = QueryFind(mysql, 'users', { firstName: 'John' }); const data = await mysql.run(query); class User extends MysqlEntity { id: number; firstName: string; lastName: string; } User.DefineSchema('users', { id: { type: MysqlDataType.INT, primaryKey: true }, firstName: { type: MysqlDataType.VARCHAR, required: true }, lastName: MysqlDataType.VARCHAR }); const users = await User.Find(mysql, { firstName: 'John' });
Debug
Known issues
breakingMysqlConnector constructor options changed: in v2.x, host and user are required; previously they were optional with defaults.
fix
Provide connection config object with host, user, password, and database properties when constructing MysqlConnector.
affects: >=2.0.0
deprecatedThe method 'QueryFind' is deprecated in favor of 'Entity.Find' static method.
fix
Use User.Find(mysql, condition) instead of QueryFind(mysql, table, condition).
affects: >=2.0.0
breakingESM-only: package no longer supports CommonJS require().
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().
affects: >=2.0.0
gotchaSchema column definitions must use uppercase property names for type, primaryKey, etc. (matching TypeScript interfaces).
fix
Ensure property names in schema objects are exactly as defined; e.g., 'type', 'primaryKey', 'required', 'default'.
affects: *
Errors
Common errors & fixes
TypeError: Cannot destructure property 'host' of 'undefined' or 'null'.
MysqlConnector instantiated without a connection config object.
fix
new MysqlConnector({ host: 'localhost', user: 'root', password: '...', database: '...' })
ReferenceError: require is not defined in ES module scope
Trying to use CJS require() with an ESM-only package.
fix
Use import statements. If necessary, use dynamic import: const { MysqlConnector } = await import('tydet-core-mysql');
Cannot read property 'prototype' of undefined
Entity classes not extending MysqlEntity correctly or missing DefineSchema call.
fix
Ensure class extends MysqlEntity and call User.DefineSchema() before using static methods.
Upgrade
Version history
2.0.3latest on npm
Audit
Dependencies
tydet-corerequiredCore library required for Context, service mounting, and entity framework.
mysql2requiredMySQL driver for Node.js.
Agent activity
17 hits · last 30 days
node
14
Meta
1
OpenAI (training)
1
Resources
tydet-core-mysql — npm install tydet-core-mysql · libregistry