Registry / database / mysql-crud-ts

mysql-crud-ts

JSON →
library0.3.0jsnpmunverified

Version 0.3.0. A lightweight, strongly typed CRUD module for MySQL databases that wraps the mysql package. Provides typed Create, Read, Update, Delete methods on a per-table basis using TypeScript generics. Simple API but requires manual mysql connection setup and table schema definitions. Currently in early development (pre-1.0), released irregularly. Differentiated by TypeScript-first design with minimal abstraction over raw MySQL operations.

npm install mysql-crud-ts
INSTALL
IMPORT
SIG · MYSQL-CRUD-TS
M
mysql-crud-ts
databasejavascriptv0.3.0
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.

default import (Crud class)
import Crud from 'mysql-crud-ts'
const Crud = require('mysql-crud-ts')
ESM default export. CommonJS require works but may not get types.
Crud
import Crud from 'mysql-crud-ts'
import { Crud } from 'mysql-crud-ts'
Default export, not named.
TypeScript usage
const Users = new Crud<UserSchema>(connection, 'users')
new Crud(connection, 'users') without generic
Generic parameter is optional but recommended for type safety.

Connects to MySQL, defines a User schema, creates a CRUD instance for the 'users' table, creates a record, and reads all records.

import mysql from 'mysql'; import Crud from 'mysql-crud-ts'; const connection = mysql.createConnection({ host: process.env.DB_HOST || 'localhost', user: process.env.DB_USER || 'root', password: process.env.DB_PASS || '', database: process.env.DB_NAME || 'test' }); connection.connect(); interface User { id: number; name: string; email: string; } const Users = new Crud<User>(connection, 'users'); async function main() { await Users.create({ id: 1, name: 'Alice', email: 'alice@example.com' }); const users = await Users.read(); console.log(users); connection.end(); } main().catch(console.error);
Debug
Known issues
gotchaRequires mysql package as peer dependency; not automatically installed.
fix
Run 'npm install mysql' alongside mysql-crud-ts.
affects: >=0.1.0
breakingBreaking: pre-1.0 API may change without notice.
fix
Pin to exact version or check changelog before updating.
affects: <1.0.0
gotchaThe 'read' method returns all rows; no filtering or pagination built-in.
fix
Use a raw query or extend with conditions via a separate library.
affects: >=0.1.0
gotchaNo connection pooling or error recovery; relies on external mysql connection.
fix
Implement retry logic or use a wrapper with connection pooling.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Crud is not a constructor
Using named import 'Crud' instead of default import.
fix
Change to 'import Crud from 'mysql-crud-ts''
Cannot find module 'mysql-crud-ts'
Package not installed or typo in module name.
fix
Run 'npm install mysql-crud-ts'
Property 'create' does not exist on type 'typeof import(...)'
Using import * as Crud instead of default import.
fix
Use 'import Crud from 'mysql-crud-ts''
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
mysqlrequiredRequired peer dependency for database connection and query execution.
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-crud-ts — npm install mysql-crud-ts · libregistry