Registry / database / sedk-mysql

sedk-mysql

JSON →
library0.1.0jsnpmunverified

Simple SQL builder and validator for MySQL dialect (v0.1.0). Written in TypeScript, it provides a fluent API to construct SELECT, INSERT, UPDATE, DELETE queries with parameterized bindings. The library enforces a database schema defined at compile time, preventing runtime schema mismatches. Key features include schema-driven column references, binding parameters via eq$() family of methods, support for JOINs (inner, left, right), and no magic strings. Current version is 0.1.0 with an initial release. Release cadence is not yet established; development is ongoing on GitHub under the sedk monorepo.

npm install sedk-mysql
INSTALL
IMPORT
SIG · SEDK-MYSQL
S
sedk-mysql
databasejavascriptv0.1.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.

Database
import { Database } from 'sedk-mysql'
const Database = require('sedk-mysql').Database
ESM module; use static import. CommonJS require is less common but possible.
builder
import { builder } from 'sedk-mysql'
import builder from 'sedk-mysql'
builder is a named export, not default.
LogicalOperator
import { LogicalOperator } from 'sedk-mysql'
import { LogicalOperator as LO } from 'sedk-mysql'
Renaming is unnecessary and may confuse code readers.
TextColumn, NumberColumn, BooleanColumn, DateColumn
import { TextColumn, NumberColumn, BooleanColumn, DateColumn } from 'sedk-mysql'
import { TextColumn, NumberColumn } from 'sedk-mysql/columns'
All exports are from the package root; no subpath exports exist yet.

Builds a SELECT query with parameterized WHERE clause using schema-driven column references and binding parameters.

import { Database, Schema, Table, TextColumn, NumberColumn, BooleanColumn, DateColumn, builder, LogicalOperator } from 'sedk-mysql' const database = new Database({ version: 1, schemas: { public: new Schema({ name: 'public', tables: { Employee: new Table({ name: 'Employee', columns: { name: new TextColumn({ name: 'name' }), salary: new NumberColumn({ name: 'salary' }), isManager: new BooleanColumn({ name: 'isManager' }), startDate: new DateColumn({ name: 'startDate' }), }, }), }, }), }, }) const Employee = database.s.public.t.Employee const name = Employee.c.name const salary = Employee.c.salary const AND = LogicalOperator.AND const sql = builder(database) const stmt = sql .select(name, salary) .from(Employee) .where(name.eq$('John'), AND, salary.gt$(1500)) .getSQL() console.log(stmt) // SELECT `name`, `salary` FROM `Employee` WHERE ( `name` = ? AND `salary` > ? ) const bindValues = sql .select(name, salary) .from(Employee) .where(name.eq$('John'), AND, salary.gt$(1500)) .getBindValues() console.log(bindValues) // [ 'John', 1500 ]
Debug
Known issues
breakingIn version 0.1.0, eq() from an aliased table now returns UpdateCondition instead of UpdateInfo, breaking code that relied on the previous type.
fix
Update to v0.1.0 and adjust code expecting UpdateInfo from aliased table eq() calls.
affects: 0.0.x
gotchaSchema definitions must be created once and reused. Defining a schema inline in each query leads to duplication and potential mismatches.
fix
Define the database schema in a separate file and export it for reuse across queries.
affects: >=0.0.1
gotchaThe library is early stage (v0.x) and may have breaking changes between minor versions. Production usage should pin exact version.
fix
Use package.json with "sedk-mysql": "0.1.0" (no caret or tilde) to lock version.
affects: >=0.0.1
deprecatedThe library currently does not support subqueries, UNION, or complex CTEs. These may be added in future versions.
fix
For advanced query features, consider alternatives like Knex.js or manually write SQL.
affects: <=0.1.0
Errors
Common errors & fixes
TypeError: database.s.public is undefined
The schema 'public' was not defined in the Database constructor or the schema name is misspelled.
fix
Ensure the schema object in the Database constructor contains a key 'public' matching the accessed path.
Cannot find module 'sedk-mysql'
Package not installed or import path is wrong.
fix
Run 'npm install sedk-mysql' and use 'import { ... } from "sedk-mysql"'.
Property 'eq$' does not exist on type 'TextColumn'
Typo or wrong method name; eq$ is used for binding parameters.
fix
Use eq$() for parameterized queries, eq() for literal values.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Meta
1
Resources
sedk-mysql — npm install sedk-mysql · libregistry