Registry / database / waterline-mysql

waterline-mysql

JSON →
library0.6.0jsnpmunverified

MySQL adapter for the Waterline ORM, providing a uniform API for accessing MySQL databases alongside other supported backends. This package is in early alpha (v0.6.0) and not production-ready. It is part of the Sails.js ecosystem and was originally developed by Balderdash. The adapter implements Waterline's query interface including create, find, update, destroy, and basic transaction support. It is no longer actively maintained; users are advised to migrate to sails-mysql or other modern MySQL adapters.

npm install waterline-mysql
INSTALL
IMPORT
SIG · WATERLINE-MYSQL
W
waterline-mysql
databasejavascriptv0.6.0
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.

adapter
import adapter from 'waterline-mysql';
const adapter = require('waterline-mysql');
Package is primarily used with Waterline's adapter configuration. Default import is typical for ESM; CommonJS require also works but will return the module.exports object.
Waterline
import Waterline from 'waterline'; const MySQLAdapter = require('waterline-mysql'); Waterline.registerAdapter(MySQLAdapter);
const MySQLAdapter = require('waterline-mysql'); // Missing registration with Waterline
Adapter must be registered with Waterline before use. CommonJS pattern shown; Waterline is an ESM-only module in later versions.
config
const config = { adapters: { 'mysql': require('waterline-mysql') }, connections: { 'myLocalMySQL': { adapter: 'mysql', host: 'localhost' } } };
const config = { adapters: { mysql: 'waterline-mysql' } }; // adapter must be the module, not a string
In Waterline config, the adapter property must be set to the required module, not just its name.

Shows how to configure and use the MySQL adapter with Waterline, including collection definition and initialization.

import Waterline from 'waterline'; import MySQLAdapter from 'waterline-mysql'; const waterline = new Waterline(); const userCollection = Waterline.Collection.extend({ identity: 'user', connection: 'myLocalMySQL', attributes: { name: { type: 'string', required: true }, email: { type: 'string', required: true } } }); waterline.loadCollection(userCollection); const config = { adapters: { 'mysql': MySQLAdapter }, connections: { 'myLocalMySQL': { adapter: 'mysql', host: process.env.MYSQL_HOST ?? 'localhost', port: process.env.MYSQL_PORT ?? 3306, user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test' } } }; waterline.initialize(config, (err, ontology) => { if (err) { console.error(err); return; } const User = ontology.collections.user; User.create({ name: 'Alice', email: 'alice@example.com' }) .then((user) => console.log('Created:', user)) .catch((err) => console.error(err)); });
Debug
Known issues
deprecatedPackage is no longer actively maintained. Use sails-mysql or another modern adapter.
fix
Migrate to sails-mysql (part of Sails.js) or use a different ORM/adapter combination.
affects: >=0.0.0
gotchaAdapter must be registered with Waterline before use; otherwise queries will fail silently.
fix
Ensure you call Waterline.registerAdapter(adapter) or pass the adapter in the config's adapters object.
affects: >=0.0.0
gotchaConnection config uses 'adapter' key, not 'adapter-type'. Using wrong key will cause connection errors.
fix
Use 'adapter' (not 'adapter-type') in the connection config object.
affects: >=0.0.0
breakingIn alpha versions (0.x), the API is unstable and may break without notice. Not production-ready.
fix
Either pin to a specific version and test thoroughly, or avoid using in production.
affects: >=0.0.0
Errors
Common errors & fixes
Error: registerAdapter is not a function
Waterline version mismatch; later versions use a different pattern for adapter registration.
fix
Use config.adapters object instead of registerAdapter: { adapters: { mysql: require('waterline-mysql') } }
Error: Cannot find module 'mysql'
Missing peer dependency 'mysql' (or 'mysql2').
fix
Run: npm install mysql (or mysql2) as a dependency.
Error: Connection failed: connect ECONNREFUSED
MySQL server not running or incorrect host/port in connection config.
fix
Verify MySQL is running and connection details are correct.
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
waterlinerequiredCore ORM dependency; adapter must be used with Waterline.
Agent activity
27 hits · last 30 days
node
20
Meta
2
Bingbot
1
OpenAI (training)
1
Resources
waterline-mysql — npm install waterline-mysql · libregistry