Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

impress

Package Overview
Dependencies
Maintainers
1
Versions
719
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

impress - npm Package Compare versions

Comparing version 0.0.24 to 0.0.25

lib/Introspection.js

7

HISTORY.md

@@ -0,1 +1,8 @@

0.0.25 / 2010-07-17
==================
* Updated mysql system metadata utilities: primary, foreign, fields, databases, tables, tableInfo
* Added mysql system metadata utilities: indexes, processes, globalVariables, globalStatus
* Updated mysql data access utilities: queryRow, queryValue, queryArray, queryHash, queryKeyValue, count
0.0.24 / 2010-07-15

@@ -2,0 +9,0 @@ ==================

125

lib/db.mysql.js

@@ -6,2 +6,4 @@ (function(db) {

var Introspection = require('./Introspection');
db.mysql = {};

@@ -22,13 +24,4 @@

connection.on('error', db.mysql.onError);
connection.queryRow = db.mysql.queryRow;
connection.queryValue = db.mysql.queryValue;
connection.queryArray = db.mysql.queryArray;
connection.queryKeyValue = db.mysql.queryKeyValue;
connection.count = db.mysql.count;
connection.primary = db.mysql.primary;
connection.foreign = db.mysql.foreign;
connection.fields = db.mysql.fields;
connection.databases = db.mysql.databases;
connection.tables = db.mysql.tables;
connection.tableInfo = db.mysql.tableInfo;
db.mysql.upgrade(connection);
Introspection.init(connection);
connection.connect();

@@ -48,39 +41,47 @@ db.connections.push(connections[i].name);

db.mysql.upgrade = function(connection) {
connection.count = function(table, callback) {
this.queryValue('SELECT count(*) FROM ??', [table], function(err, res) {
callback(err, res);
});
}
// Returns single row as associative array of fields
//
db.mysql.queryRow = function(query, values, callback) {
this.query(query, values, function(err, res) {
connection.queryRow = function(sql, values, callback) {
this.query(sql, values, function(err, res, fields) {
if (err) res = false; else res = res[0] ? res[0] : false;
callback(err, res);
callback(err, res, fields);
});
}
// Returns single value
// Returns single value (scalar)
//
db.mysql.queryValue = function(query, values, callback) {
this.queryRow(query, values, function(err, res) {
connection.queryValue = function(sql, values, callback) {
this.queryRow(sql, values, function(err, res, fields) {
if (err) res = false; else res = res[Object.keys(res)[0]];
callback(err, res);
callback(err, res, fields);
});
}
// Query associative array, first field will be array key
// Query returning array of first field values
//
db.mysql.queryArray = function(query, values, callback) {
this.query(query, values, function(err, res) {
var result = {};
connection.queryArray = function(sql, values, callback) {
this.query(sql, values, function(err, res, fields) {
var result = [];
if (err) result = false; else {
for (var i in res) {
var row = res[i];
result[row[Object.keys(row)[0]]] = row;
result.push(row[Object.keys(row)[0]]);
}
}
callback(err, result);
callback(err, result, fields);
});
}
// Query key-value array, first field will be key and second will be value
// Query returning hash (associative array), first field will be array key
//
db.mysql.queryKeyValue = function(query, values, callback) {
this.query(query, values, function(err, res) {
connection.queryHash = function(sql, values, callback) {
this.query(sql, values, function(err, res, fields) {
var result = {};

@@ -90,77 +91,27 @@ if (err) result = false; else {

var row = res[i];
result[row[Object.keys(row)[0]]] = row[Object.keys(row)[1]];
result[row[Object.keys(row)[0]]] = row;
}
}
callback(err, result);
callback(err, result, fields);
});
}
db.mysql.count = function(table, where, callback) {
var sql = 'SELECT count(*) FROM ??';
if (where) sql = sql+' where '+where;
this.queryValue(sql, [table], function(err, res) {
callback(err, res);
});
}
db.mysql.primary = function(table, callback) {
this.queryRow('SHOW KEYS FROM ?? WHERE Key_name = "PRIMARY"', [table], function(err, res) {
callback(err, res);
});
}
db.mysql.foreign = function(table, callback) {
this.query(
'SELECT CONSTRAINT_NAME, COLUMN_NAME, ORDINAL_POSITION, POSITION_IN_UNIQUE_CONSTRAINT, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME '+
'FROM information_schema.KEY_COLUMN_USAGE '+
'WHERE REFERENCED_TABLE_NAME IS NOT NULL AND CONSTRAINT_SCHEMA = ? AND TABLE_NAME = ? '+
'ORDER BY REFERENCED_TABLE_NAME',
['mezha', table],
function(err, res) {
if (err) res = false;
callback(err, res);
}
);
}
db.mysql.fields = function(table, callback) {
this.query('SHOW FULL COLUMNS FROM ??', [table], function(err, res) {
if (err) res = false;
callback(err, res);
});
}
db.mysql.databases = function(mask, callback) {
this.query('SHOW DATABASES LIKE ?', [mask], function(err, res) {
var result = [];
// Query returning key-value array, first field of query will be key and second will be value
//
connection.queryKeyValue = function(sql, values, callback) {
this.query(sql, values, function(err, res, fields) {
var result = {};
if (err) result = false; else {
for (var i in res) {
var row = res[i];
result.push(row[Object.keys(row)[0]]);
result[row[Object.keys(row)[0]]] = row[Object.keys(row)[1]];
}
}
callback(err, result);
callback(err, result, fields);
});
}
db.mysql.tables = function(mask, callback) {
this.query('SHOW TABLES LIKE ?', [mask], function(err, res) {
var result = [];
if (err) result = false; else {
for (var i in res) {
var row = res[i];
result.push(row[Object.keys(row)[0]]);
}
}
callback(err, result);
});
}
db.mysql.tableInfo = function(table, callback) {
this.query('SHOW TABLE STATUS LIKE ?', [table], function(err, res) {
if (err) res = false;
callback(err, res);
});
}
} (global.db = global.db || {}));
{
"name": "impress",
"version": "0.0.24",
"version": "0.0.25",
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>",

@@ -5,0 +5,0 @@ "description": "Impressive totalitarian style multipurpose web application server. All decisions are made. Ready for applied development.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc