Registry / database / mysql-stream-db

mysql-stream-db

JSON →
library0.1.1jsnpmunverified

A streaming ORM for MySQL databases, currently at version 0.1.1. This package is in early development (no recent updates) and provides a leveldb-style interface for MySQL tables using Node.js streams. It offers a simple API for CRUD operations (put, get, del) and streaming reads/writes via createReadStream, createKeyStream, and createWriteStream. Unlike full-featured ORMs like Sequelize or TypeORM, it focuses on minimal abstraction and stream-based data handling. Note: many options (sort, limit, page) are marked as TODO and not implemented. The package depends on the mysql npm package for database connections.

npm install mysql-stream-db
INSTALL
IMPORT
SIG · MYSQL-STREAM-DB
M
mysql-stream-db
databasejavascriptv0.1.1
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.

connect
const { connect } = require('mysql-stream-db');
import { connect } from 'mysql-stream-db';
This package uses CommonJS (require) module system. ESM import patterns will fail.
DB
const dbStream = require('mysql-stream-db'); const db = dbStream.connect();
const db = require('mysql-stream-db').DB.connect();
There is no direct 'DB' export. Use the connect function to obtain a DB instance.
Table
After connecting: const table = db.table('users'); (requires prior registration with db.registerTable)
const Table = require('mysql-stream-db').Table;
Table instances are created via db methods, not imported directly.

Establishes MySQL connection, registers a table, inserts a row, retrieves it, and demonstrates a read stream.

const mysqlStream = require('mysql-stream-db'); const db = mysqlStream.connect({ host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test' }); db.registerTable('users', { fields: ['id', 'name', 'email'], primaryKey: 'id' }); const users = db.table('users'); users.put({ name: 'Alice', email: 'alice@example.com' }, (err, result) => { if (err) throw err; console.log('Inserted row with id:', result.insertId); }); users.get({ email: 'alice@example.com' }, (err, row) => { if (err) throw err; console.log('Found user:', row); }); // Stream all rows users.createReadStream() .on('data', row => console.log('Row:', row)) .on('end', () => console.log('Done'));
Debug
Known issues
breakingThe npm package 'mysql-stream-db' has been deprecated and is no longer maintained. It depends on an outdated version of the 'mysql' package which has known security vulnerabilities.
fix
Use an alternative ORM such as Sequelize, TypeORM, or knex with mysql2.
affects: *
breakingThe 'sort', 'limit', and 'page' options in table.get() are marked as TODO and not implemented. Using them will have no effect.
fix
Do not rely on these options; handle sorting/pagination manually via SQL queries.
affects: <=0.1.1
gotchaThe 'put' method attempts an INSERT first. If it fails with ER_DUP_ENTRY and the row includes the primary key, it performs an UPDATE. This may cause unexpected behavior if the row contains a primary key that doesn't exist yet (insert will succeed, but if the primary key exists, update runs).
fix
Ensure that when using 'put', the row object includes the primary key if you intend an update, or omit it for a pure insert.
affects: *
gotchaTable must be registered with db.registerTable() before calling db.table(). Attempting to access an unregistered table will throw an error.
fix
Always call db.registerTable() first.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'createReadStream')
Accessing a table that hasn't been registered with db.registerTable().
fix
Ensure the table is registered before calling db.table(): db.registerTable('myTable', { fields: [...] }) then db.table('myTable').
Error: ER_DUP_ENTRY: Duplicate entry 'x' for key 'PRIMARY'
The 'put' method could not update because the row didn't include the primary key, or the primary key didn't match.
fix
Include the primary key value in the row object when calling put().
Cannot find module 'mysql-stream-db'
Package is unpublished or not installed. The package is deprecated and may have been removed from npm registry.
fix
Do not install this package. Use an alternative like 'sequelize' or 'knex'.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
mysqlrequiredProvides the underlying MySQL connection driver
Agent activity
2 hits · last 30 days
node
2
Resources
mysql-stream-db — npm install mysql-stream-db · libregistry