Registry / database / node-workhorse-mysql

node-workhorse-mysql

JSON →
library1.0.1jsnpmunverified

Extensions for Node Workhorse to persist data in MySQL. Version 1.0.1 enables storing workhorse job queues and state in a MySQL database. Provides integration patterns for MySQL with the workhorse task queue system. TypeScript definitions included. Suitable for projects already using Node Workhorse and seeking durable storage backend.

npm install node-workhorse-mysql
INSTALL
IMPORT
SIG · NODE-WORKHORSE-MYS
N
node-workhorse-mysql
databasejavascriptv1.0.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.

MysqlBackend
import { MysqlBackend } from 'node-workhorse-mysql'
const MysqlBackend = require('node-workhorse-mysql')
ESM-only since v1.0.0
MysqlBackend
import MysqlBackend from 'node-workhorse-mysql'
const MysqlBackend = require('node-workhorse-mysql').default
Default export is available but named export is preferred.
SqlBackend
import { SqlBackend } from 'node-workhorse-mysql'
Also exported as SqlBackend, use if you want generic SQL backend.

Initializes a MysqlBackend and sets up a Workhorse instance for queuing jobs.

import { Workhorse } from 'node-workhorse'; import { MysqlBackend } from 'node-workhorse-mysql'; const backend = new MysqlBackend({ host: process.env.MYSQL_HOST || 'localhost', user: process.env.MYSQL_USER || 'root', password: process.env.MYSQL_PASS || '', database: process.env.MYSQL_DB || 'workhorse', }); const workhorse = new Workhorse({ backend }); // Add a job workhorse.add({ task: 'email', data: { to: 'user@example.com' } });
Debug
Known issues
gotchaMysqlBackend constructor requires options, not a connection string.
fix
Provide an object with host, user, password, database keys.
affects: >=1.0.0
gotchaMySQL connection pool is not automatically closed; call `backend.close()` to release resources.
fix
Ensure you close the backend when shutting down your application.
affects: >=1.0.0
breakingVersion 1.0.0 dropped support for callbacks; only promises are supported.
fix
Use async/await or .then() instead of callbacks.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'node-workhorse-mysql'
Package not installed or typo in import
fix
Run `npm install node-workhorse-mysql` and ensure import path is correct.
MysqlBackend is not a constructor
Importing incorrectly or using CommonJS with named import
fix
Use `import { MysqlBackend } from 'node-workhorse-mysql'`.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
node-workhorserequiredCore package for task queue functionality
Agent activity
5 hits · last 30 days
node
4
Resources
node-workhorse-mysql — npm install node-workhorse-mysql · libregistry