Registry / database / wires-mysql

wires-mysql

JSON →
library0.0.7jsnpmunverified

An API for MySQL that supports MongoDB-style queries, version 0.0.7. This library provides a convenient wrapper for common MySQL operations (insert, update, select, delete) using familiar MongoDB-like query syntax. It includes automatic schema synchronization, JSON column type support, and connection pooling. Wires-mysql is particularly useful for developers transitioning from MongoDB to MySQL or those who prefer a document-oriented query interface. The package is in early development with minimal documentation and no recent updates.

npm install wires-mysql
INSTALL
IMPORT
SIG · WIRES-MYSQL
W
wires-mysql
databasejavascriptv0.0.7
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.

mosql
const mosql = require('wires-mysql');
import mosql from 'wires-mysql';
This package is CommonJS-only and does not support ESM imports.
Operation
const Operation = require('wires-mysql').operations.Operation;
import { Operation } from 'wires-mysql';
Operation is nested under the exported object.
schema.Sync
const Sync = require('wires-mysql').schema.Sync;
const Sync = require('wires-mysql').Sync;
Sync is under the schema property.

Complete example: connect to MySQL, sync schema, insert a user, and run a select query using MongoDB-like operators.

const mosql = require('wires-mysql'); // Create connection pool mosql.connection.createPool({ host: 'localhost', user: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test' }); // Define schema const userSchema = { id: {}, name: {}, email: {}, age: { type: 'int' } }; // Sync schema const sync = new mosql.schema.Sync([{ name: 'users', schema: userSchema }]); sync.start(() => { console.log('Schema synced'); }); // Insert a record const insert = mosql.operations.Operation.provide('users', 'insert', userSchema); insert.setData({ name: 'Test', email: 'test@example.com', age: 31 }); insert.request((err, newId) => { if (err) console.error(err); else console.log('Inserted ID:', newId); }); // Select with MongoDB-style query const select = mosql.operations.Operation.provide('users', 'select', userSchema); select.where({ id: { $gt: 1 } }) .order({ id: 'desc' }) .limit(1) .offset(1) .group(['name']) .request((err, res) => { if (err) console.error(err); else console.log('Results:', res); });
Debug
Known issues
gotchaSchema is required for all operations; missing schema will cause errors.
fix
Always pass a schema object to Operation.provide().
affects: >=0.0.0
gotchaJSON columns are not automatically handled unless type is set to 'json', 'json-med', or 'json-large'.
fix
Set column type to 'json' for objects to be automatically serialized/deserialized.
affects: >=0.0.0
gotchaThe package is CommonJS only; attempting to import with ES modules will fail.
fix
Use require() instead of import.
affects: >=0.0.0
gotchaVersion 0.0.7 is very early and may contain unstable APIs or undocumented breaking changes.
fix
Pin version and test thoroughly.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: mosql.schema.Sync is not a constructor
Incorrect import path; Sync is nested under schema.
fix
Use `new mosql.schema.Sync(tables)`
Error: Schema must be defined
Operation.provide() called without a schema.
fix
Pass a valid schema object as the third argument.
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
18
Meta
2
OpenAI (training)
1
Resources
wires-mysql — npm install wires-mysql · libregistry