Registry / database / go-mysql-js

go-mysql-js

JSON →
library0.3.4jsnpmunverified

A Node.js library wrapping the Go go-mysql package to provide MySQL binlog replication and a MySQL client connector. Version 0.3.4 is the latest stable release, with irregular updates as a wrapper project. Key features include synchronous-style async connection, binlog event parsing, and table filtering via regex. Compared to mysql2 and @mysql/xdevapi, it focuses specifically on binlog streaming and is not a general-purpose MySQL driver.

npm install go-mysql-js
INSTALL
IMPORT
SIG · GO-MYSQL-JS
G
go-mysql-js
databasejavascriptv0.3.4
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
import MysqlBinlog from 'go-mysql-js'
const MysqlBinlog = require('go-mysql-js')
Package uses ESM default export. CJS require may not work without bundler.
MysqlBinlog (type)
import type { MysqlBinlog } from 'go-mysql-js'
TypeScript users can import the type separately for type annotations.
MysqlBinlogOptions
import { MysqlBinlogOptions } from 'go-mysql-js'
Named export for configuration interface.

Creates a MySQL binlog syncer, listens for row events, and handles cleanup on interrupt.

import MysqlBinlog from 'go-mysql-js'; async function main() { const syncer = await MysqlBinlog.create({ hostname: process.env.DB_HOST ?? 'localhost', port: Number(process.env.DB_PORT) || 3306, username: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', tableRegexes: ['Users'], serverId: 100, // unique server ID for replication }); syncer.on('event', (event) => { console.log('got row event', event); }); syncer.on('error', (err) => { console.error('got error', err); }); process.on('SIGINT', () => { syncer.close(); process.exit(0); }); } main().catch(err => { console.error(err); process.exit(1); });
Debug
Known issues
gotchaNative binary: requires Go installed and node-gyp build during install
fix
Install Go (>=1.16) and ensure node-gyp dependencies (python, make, C++ compiler) are available.
affects: >=0.0.0
gotchatableRegexes expects raw table names, not fully qualified db.table strings
fix
Use simple table name, e.g., 'Users' instead of 'mydb.Users'.
affects: >=0.0.0
deprecatedConstructor options 'hostname' and 'port' may be deprecated in favor of connection URI
fix
Check latest docs; consider using 'connectionUri' option if available.
affects: =0.3.4
breakingIn v0.3.0, 'create' changed from synchronous to async, returning a Promise
fix
Await the result: const syncer = await MysqlBinlog.create(...)
affects: >=0.3.0 <0.4.0
Errors
Common errors & fixes
Error: Module not found: Can't resolve 'go-mysql-js'
Package not installed or bundler misconfiguration
fix
Run 'npm install go-mysql-js' and ensure no ESM/CJS mismatch in your bundler.
TypeError: MysqlBinlog.create is not a function
Using default import incorrectly (e.g., importing non-default instead of default)
fix
Use import MysqlBinlog from 'go-mysql-js' (ESM default) or const { default: MysqlBinlog } = require(...) (CJS).
Error: Go binary build failed
Missing Go installation or node-gyp build environment
fix
Install Go (>=1.16) and required build tools (python, make, C++ compiler).
Upgrade
Version history
0.3.4latest on npm
Audit
Dependencies
node-gyp-buildrequiredBundles native Go binary using node-gyp
Agent activity
8 hits · last 30 days
node
6
Resources
go-mysql-js — npm install go-mysql-js · libregistry