Registry / database / sharedb-mysql

sharedb-mysql

JSON →
library1.0.5jsnpmunverified

MySQL database adapter for ShareDB that serves as both a snapshot store and op log. Version 1.0.5 is current (last updated 2018). It wraps the mysql npm package and supports standard MySQL configuration options, custom table names for ops and snapshots, and debug mode. Compared to other ShareDB adapters (e.g., MongoDB), this provides direct MySQL integration for teams already using MySQL. Release cadence is low; maintenance appears minimal.

npm install sharedb-mysql
INSTALL
IMPORT
SIG · SHAREDB-MYSQL
S
sharedb-mysql
databasejavascriptv1.0.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 export
const mySQLDB = require('sharedb-mysql')(mysqlOptions);
const mySQLDB = require('sharedb-mysql'); // missing invocation; returns a function that must be called
sharedb-mysql exports a function that takes MySQL options and returns a db object.
ShareDB backend
const backend = require('sharedb')({db: mySQLDB});
const backend = require('sharedb')({db: require('sharedb-mysql')(...)}); // correct, but missing options
ShareDB expects a db object with commit, getSnapshot, etc.
require('sharedb-mysql')
const sharedbMysql = require('sharedb-mysql');
import sharedbMysql from 'sharedb-mysql'; // package does not support ESM; use require
Package uses CommonJS only; no ESM or TypeScript types.

Creates a MySQL-backed ShareDB backend, connects a document, and fetches it from the database.

const mysqlOptions = { db: { host: 'localhost', user: 'root', password: '', database: 'somedb' }, ops_table: 'ops', snapshots_table: 'snapshots', debug: false }; const mySQLDB = require('sharedb-mysql')(mysqlOptions); const ShareDB = require('sharedb'); const backend = ShareDB({ db: mySQLDB }); const connection = backend.connect(); const doc = connection.get('users', '123'); doc.fetch(function(err) { if (err) throw err; console.log('Document fetched'); });
Debug
Known issues
gotchaPackage is no longer actively maintained; last update was 4 years ago.
fix
Consider alternative adapters like sharedb-mongo or sharedb-postgres for ongoing support.
affects: >=1.0.0
breakingMySQL connection errors are passed back directly; no custom error handling.
fix
Wrap backend calls in try-catch or handle error callbacks to manage MySQL failures.
affects: >=1.0.0
gotchaThe mysql package must be installed separately; it is a required peer dependency.
fix
Run 'npm install mysql' to install the MySQL client.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
mysql package not installed; it is a required dependency but not bundled.
fix
npm install mysql
TypeError: sharedbMysql is not a function
Attempting to use sharedb-mysql directly without calling it as a function.
fix
Use const mySQLDB = require('sharedb-mysql')(mysqlOptions);
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'
Invalid MySQL credentials or missing database.
fix
Verify MySQL connection settings in mysqlOptions.db.
Upgrade
Version history
1.0.5latest on npm
Audit
Dependencies
mysqlrequiredProvides MySQL client library; sharedb-mysql wraps this package.
sharedbrequiredPeer dependency; required to use the adapter.
Agent activity
10 hits · last 30 days
node
8
Meta
2
Resources
sharedb-mysql — npm install sharedb-mysql · libregistry