Registry / database / sc-crud-mysql

sc-crud-mysql

JSON →
library0.6.5jsnpmunverified

Realtime CRUD data management layer/plugin for SocketCluster using MySQL as the database. Current stable version is 0.6.5 (infrequent updates, last release likely 2018). Provides server-side attach and client-side socket events (create, read, update, delete) with optional conditionals, joins, expressions, ordering, pagination, and basic SQL injection protection. Differentiated by tight SocketCluster integration and realtime broadcasting; however, it is unmaintained and lacks modern features like async/await or ESM support.

npm install sc-crud-mysql
INSTALL
IMPORT
SIG · SC-CRUD-MYSQL
S
sc-crud-mysql
databasejavascriptv0.6.5
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
var scCrudMysql = require('sc-crud-mysql')
import scCrudMysql from 'sc-crud-mysql'
CommonJS only; no ESM or TypeScript typings.
.attach
scCrudMysql.attach(worker, options)
scCrudMysql(options)
attach() is the main method; passing options directly is incorrect.
socket events
socket.emit('create', { table, post }, callback)
socket.emit('create', { tab: 'users' })
Event names are 'create', 'read', 'update', 'delete'; misspelling or wrong payload keys cause silent failures.

Attach the plugin to a SocketCluster worker on the server, then emit CRUD events from the client.

// server-side worker.js var scCrudMysql = require('sc-crud-mysql'); module.exports.run = function (worker) { scCrudMysql.attach(worker, { db: { host: process.env.MYSQL_HOST || 'localhost', user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASSWORD || '', database: process.env.MYSQL_DATABASE || 'test' } }); }; // client-side var socket = socketCluster.connect({ hostname: 'localhost', port: 3000 }); socket.on('connect', function (status) { socket.emit('create', { table: 'users', post: { first: 'John', last: 'Doe', email: 'john@example.com' }, unique: true, unique_by: 'id' }, function (err, newUser) { if (err) console.error(err); else console.log('Created user:', newUser); }); });
Debug
Known issues
breakingNo versioning adherence; breaking changes may occur in minor/patch increments (e.g., 0.4.0 added joins, 0.5.0 changed SQL injection behavior).
fix
Pin to exact version and test all interactions.
affects: <=0.6.5
deprecatedPackage is unmaintained; no updates since 2018.
fix
Migrate to an alternative like Slick or write custom middleware.
affects: *
gotchaSocketCluster version compatibility: requires SocketCluster v5.x or earlier; not tested with v6+.
fix
Use SocketCluster v5.x or check issues for compatibility patches.
affects: *
gotchaSQL injection protection is basic; user input in conditionals or custom fields may still be vulnerable.
fix
Upgrade to 0.5.0+ and validate/sanitize all input server-side.
affects: <0.5.0
gotchaNo TypeScript definitions; using in TypeScript project requires manual type declarations or 'any' casts.
fix
Create a .d.ts file or use @ts-ignore.
affects: *
Errors
Common errors & fixes
Cannot find module 'sc-crud-mysql'
Package not installed or missing from node_modules.
fix
Run 'npm install sc-crud-mysql --save' in the project root.
scCrudMysql.attach is not a function
Incorrect import or the module resolved to an older version.
fix
Ensure using CommonJS require: var scCrudMysql = require('sc-crud-mysql'); and version 0.6.5.
ER_ACCESS_DENIED_ERROR: Access denied for user
Database credentials invalid or wrong host.
fix
Check MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD environment variables or db options.
socket.emit is not a function
Socket not connected or socket variable is undefined.
fix
Ensure socketCluster.connect() is called and the socket has connected before emitting.
Upgrade
Version history
0.6.5latest on npm
Audit
Dependencies
mysqlrequiredMySQL database driver
socketclusterrequiredPeer dependency for SocketCluster integration
Agent activity
6 hits · last 30 days
node
4
Meta
2
Resources
sc-crud-mysql — npm install sc-crud-mysql · libregistry