Registry / database / fastcar-mysql

fastcar-mysql

JSON →
library0.1.24jsnpmunverified

An ORM wrapper for mysql2 within the fastcar-core framework (v0.1.24). Provides structured entity-mapper patterns via decorators (@Table, @Field, @PrimaryKey) and integrates with fastcar-core's dependency injection (@Repository, @Autowired). Supports CRUD, raw SQL, multi-datasource, and slow query logging. Ships TypeScript types. Requires Node >=16 and peer dependencies fastcar-core, fastcar-timer, and nanoid (3.3.4). Key differentiator: tight coupling with the fastcar ecosystem for decorator-based data mapping and lifecycle management.

npm install fastcar-mysql
INSTALL
IMPORT
SIG · FASTCAR-MYSQL
F
fastcar-mysql
databasejavascriptv0.1.24
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.

EnableMysql
import { EnableMysql } from 'fastcar-mysql/annotation'
import { EnableMysql } from 'fastcar-mysql'
EnableMysql is exported from 'fastcar-mysql/annotation' subpath.
MysqlMapper
import { MysqlMapper } from 'fastcar-mysql'
import { MysqlMapper } from 'fastcar-mysql/mapper'
MysqlMapper is a named export from the package root.
MysqlDataSourceManager
import { MysqlDataSourceManager } from 'fastcar-mysql'
Exported from package root for configuration and lifecycle management.

Shows minimal setup: enable mysql with decorator, define an entity, create a mapper, and inject into a service for querying.

import { EnableMysql } from 'fastcar-mysql/annotation'; import { Application, Autowired, Service } from 'fastcar-core/annotation'; import { MysqlMapper } from 'fastcar-mysql'; import { Entity, Repository, Field, PrimaryKey, Table } from 'fastcar-core/annotation'; @Application @EnableMysql class App { app!: FastCarApplication; } export default new App(); @Table('user') class User { @Field('id') @PrimaryKey id!: number; @Field('name') name!: string; } @Entity(User) @Repository class UserMapper extends MysqlMapper<User> {} @Service class UserService { @Autowired mapper!: UserMapper; async getUser(id: number) { return this.mapper.selectOne({ where: { id } }); } }
Debug
Known issues
breakingRequires Node >=16
fix
Upgrade Node to v16 or higher.
affects: >=0.1.0
gotchaImport paths differ: EnableMysql from 'fastcar-mysql/annotation', MysqlMapper from 'fastcar-mysql'
fix
Use correct import statements as documented.
affects: >=0.1.0
deprecatednanoid peer dep pinned to 3.3.4 – may conflict with newer nanoid versions
fix
Install nanoid@3.3.4 explicitly if using npm <7.
affects: >=0.1.0
gotchaMissing reflect-metadata import leads to decorator metadata not being emitted
fix
Add import 'reflect-metadata' at the top of your entry file.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'fastcar-mysql/annotation'
Wrong import path or package not installed
fix
Use 'import { EnableMysql } from "fastcar-mysql/annotation"' and ensure fastcar-mysql is installed.
TypeError: Class extends value undefined is not a constructor or null
Circular dependency or missing peer dependency (fastcar-core)
fix
Install fastcar-core and fastcar-timer as peer dependencies.
ReferenceError: require is not defined in ES module scope
Using CommonJS require in ESM project
fix
Use import syntax instead of require().
Error: Cannot use import statement outside a module
Missing type: module in package.json or wrong file extension
fix
Add "type": "module" to package.json or rename file to .mjs.
Upgrade
Version history
0.1.24latest on npm
Audit
Dependencies
fastcar-corerequiredCore framework providing annotation decorators and DI
fastcar-timerrequiredTimer utility for slow query logging
nanoidrequiredUnique ID generation (pinned to 3.3.4)
Agent activity
4 hits · last 30 days
node
4
Resources
fastcar-mysql — npm install fastcar-mysql · libregistry