Registry / database / mysql-model

mysql-model

JSON →
library0.0.3jsnpmunverified

A lightweight, Backbone-inspired ORM for Node.js that wraps felixge/node-mysql to provide model-based CRUD operations on MySQL databases. Version 0.0.3 is the latest and likely final release, with no updates since its initial publication. It offers a familiar extend/save/find/remove pattern for developers coming from Backbone.js, but requires manual creation of connection instances and lacks modern features like promise support, migrations, or schema validation. Alternatives like Sequelize, Bookshelf, or Knex are more actively maintained and feature-rich.

npm install mysql-model
INSTALL
IMPORT
SIG · MYSQL-MODEL
M
mysql-model
databasejavascriptv0.0.3
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
✓ const mysqlModel = require('mysql-model');
✗ import mysqlModel from 'mysql-model';
Package uses CommonJS, no default ESM export available.
mysqlModel.createConnection
✓ const MyModel = mysqlModel.createConnection({ host: '...' });
✗ const MyModel = new mysqlModel.createConnection({ host: '...' });
createConnection is a static method, not a constructor.
MyModel.extend
✓ const Movie = MyModel.extend({ tableName: 'movies' });
✗ const Movie = MyModel.extends({ tableName: 'movies' });
Uses Backbone's extend pattern.

Creates a database connection, defines a Movie model, and saves a new record.

const mysqlModel = require('mysql-model'); const MyAppModel = mysqlModel.createConnection({ host: process.env.DB_HOST || 'localhost', user: process.env.DB_USER || 'root', password: process.env.DB_PASS || '', database: process.env.DB_NAME || 'test' }); const Movie = MyAppModel.extend({ tableName: 'movies' }); const movie = new Movie({ name: 'Serenity', year: 2005 }); movie.save(function(err) { if (err) console.error(err); else console.log('Saved movie with id:', movie.get('id')); });
Debug
Known issues
deprecatedPackage is effectively abandoned; no updates since 2015. Use at your own risk in production.
fix
Migrate to an actively maintained ORM like Sequelize or Bookshelf.
affects: >=0.0.1
gotchaThe library expects 'backbone' to be installed separately, but does not list it as a dependency in package.json.
fix
Run 'npm install backbone' explicitly.
affects: >=0.0.1
gotchaModel instances are eventful (Backbone events) which may cause memory leaks if not properly cleaned up.
fix
Call movie.off() or movie.remove() when done.
affects: >=0.0.1
breakingThe 'save' method does not support partial updates; it sends the entire model attributes as the SQL SET clause.
fix
Manually set attributes before calling save, or use 'query' for custom SQL.
affects: >=0.0.1
Errors
Common errors & fixes
Error: Cannot find module 'backbone'
Backbone is not automatically installed as a dependency of mysql-model.
fix
npm install backbone
TypeError: mysqlModel.createConnection is not a constructor
Calling new on createConnection instead of using it as a static method.
fix
const MyAppModel = mysqlModel.createConnection({...}); // no new
Error: ER_ACCESS_DENIED_ERROR: Access denied for user ...
Invalid database credentials passed to createConnection.
fix
Verify host, user, password, and database values.
Upgrade
Version history
0.0.3latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver for database connections and queries.
backbonerequiredUsed for model inheritance and event system.
Agent activity
8 hits · last 30 days
node
8
Resources
mysql-model — npm install mysql-model · libregistry