Registry /
database / orange-dragonfly-orm-mysql
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.
MySQLDriver
✓ import MySQLDriver from 'orange-dragonfly-orm-mysql'
Default export. No named export; must be imported as default.
AbstractQuery
✓ import { AbstractQuery } from 'orange-dragonfly-orm'
✗ import { AbstractQuery } from 'orange-dragonfly-orm-mysql'
AbstractQuery is part of the core ORM, not the MySQL driver.
ActiveRecord
✓ import { ActiveRecord } from 'orange-dragonfly-orm'
✗ import ActiveRecord from 'orange-dragonfly-orm'
ActiveRecord is a named export, not default.
Install packages, define models with relations, register MySQL driver, query all brands, and close connection.
npm i orange-dragonfly-orm orange-dragonfly-orm-mysql orange-dragonfly-validator
// main.ts
import { AbstractQuery, ActiveRecord, Relation } from 'orange-dragonfly-orm'
import MySQLDriver from 'orange-dragonfly-orm-mysql'
class Brand extends ActiveRecord {
static get available_relations() {
return {
models: Relation.children(this, this.model('CarModel')),
}
}
}
class CarModel extends ActiveRecord {}
AbstractQuery.registerDB(new MySQLDriver({
host: process.env.MYSQL_HOST ?? 'localhost',
port: parseInt(process.env.MYSQL_PORT ?? '3306', 10),
user: process.env.MYSQL_USER ?? 'root',
password: process.env.MYSQL_PASSWORD ?? '',
database: process.env.MYSQL_DB ?? 'mydb',
}))
ActiveRecord.registerModel(Brand)
ActiveRecord.registerModel(CarModel)
const brands = await Brand.all()
console.log(brands)
await AbstractQuery.releaseDB()
Errors
Common errors & fixes
Error: Cannot find module 'orange-dragonfly-orm'
Missing core peer dependency
fixnpm install orange-dragonfly-orm
Error: registerDB expects an instance of AbstractDriver
Importing MySQLDriver incorrectly
fixUse default import: import MySQLDriver from 'orange-dragonfly-orm-mysql'
TypeError: driver.connect is not a function
Calling .connect() on MySQLDriver instance; the driver's connect is managed internally
fixDo not call .connect() manually. Connection happens on first query via AbstractQuery
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
MySQL 8+ default authentication plugin (caching_sha2_password) may not be supported by the underlying mysql2 driver
fixALTER USER 'user'@'host' IDENTIFIED WITH mysql_native_password BY 'password'; or use a compatible authentication plugin
Audit
Dependencies
orange-dragonfly-ormrequiredCore ORM package required; provides base classes like ActiveRecord, AbstractQuery, Relation
orange-dragonfly-validatoroptionalPeer dependency for validation (optional but installed automatically with npm 7+)