Registry / database / smart-mysql

smart-mysql

JSON →
library0.9.19jsnpmunverified

smart-mysql is a Node.js library that allows developers to interact with MySQL databases using NoSQL-style commands, such as insert, update, delete, and select with simple JavaScript objects, abstracting away raw SQL. The current version is 0.9.19, with no recent updates since 2015, indicating it is likely abandoned. It provides a MongoDB-like API familiar to developers transitioning from NoSQL databases, but lacks modern features, proper error handling, and is not production-ready. It differs from alternatives like knex or sequelize by being lighter and simpler, but is largely unmaintained and insecure.

npm install smart-mysql
INSTALL
IMPORT
SIG · SMART-MYSQL
S
smart-mysql
databasejavascriptv0.9.19
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.

smart_mysql
✓ const smart_mysql = require('smart-mysql');
✗ import smart_mysql from 'smart-mysql';
Library does not support ES modules; only CommonJS require works.
new smart_mysql
✓ const db = new smart_mysql({ host: 'localhost', user: 'root', password: '', charset: 'utf8_unicode_ci', database: 'avl' });
✗ const db = smart_mysql({...});
Must use new keyword to instantiate.
db.collection
✓ db.collection('user');
✗ db.table('user');
Method is named collection, not table; table is a separate query method.

Demonstrates basic CRUD operations: insert, select with table, update, and delete using NoSQL-style objects.

const smart_mysql = require('smart-mysql'); const db = new smart_mysql({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', charset: 'utf8_unicode_ci', database: process.env.DB_NAME ?? 'test' }); db.collection('user').insert({ name: 'John', age: 30 }, function(done) { if (done) console.log('Insert successful'); }); db.collection('user').table(['id', 'name'], { age: 30 }, function(data) { console.log('Selected:', data); }); db.collection('user').update({ name: 'Jane' }, { age: 30 }, function(done) { if (done) console.log('Update done'); }); db.collection('user').delete({ id: 1 }, function(done) { if (done) console.log('Deleted'); });
Debug
Known issues
gotchaCallbacks use a single boolean parameter indicating success, not results or error objects.
fix
Do not expect callback to return rows or error objects; it only returns truthy/falsy.
affects: *
gotchaThe Insert method (capital I) has different signature than insert (lowercase). Insert expects an array as first element.
fix
Use db.collection('user').insert({...}) for single inserts, not Insert.
affects: *
deprecatedSyntax for update and delete conditions is not escaped; vulnerable to SQL injection.
fix
Avoid using this library in production. Migrate to a maintained ORM with parameterized queries.
affects: *
breakingThe library is no longer maintained and may not work with Node.js versions > 10 or newer MySQL versions.
fix
Use an actively maintained ORM like knex or sequelize.
affects: >=0.9.19
Errors
Common errors & fixes
TypeError: smart_mysql is not a constructor
Forgot 'new' keyword when instantiating the class.
fix
const db = new smart_mysql({...});
Cannot find module 'smart-mysql'
Library not installed or Node.js cannot resolve the require.
fix
Run 'npm install smart-mysql' and ensure node_modules is present.
TypeError: db.collection(...).insert is not a function
Typo in method name or using Insert with capital I incorrectly.
fix
Use lowercase db.collection('user').insert({data}, callback).
“done” callback never fires or returns undefined
MySQL connection error or missing database/table.
fix
Check database credentials and ensure table exists. Add error logging to callback.
Upgrade
Version history
0.9.19latest on npm
Audit
Dependencies
mysqlrequiredUnderlying driver for MySQL connections
Agent activity
6 hits · last 30 days
node
6
Resources
smart-mysql — npm install smart-mysql · libregistry