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

mysql-wrap-production

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql-wrap-production - npm Package Compare versions

Comparing version 0.5.5 to 0.6.0

2

gruntfile.js

@@ -5,3 +5,3 @@ module.exports = function (grunt) {

all: {
options: { reporter: 'dot' },
// options: { reporter: 'dot' },
src: ['test/**/*.js']

@@ -8,0 +8,0 @@ }

{
"name": "mysql-wrap-production",
"version": "0.5.5",
"version": "0.6.0",
"description": "Mysql interface and helper functions, wrapping node-mysql",

@@ -5,0 +5,0 @@ "main": "src/mysql-wrap.js",

@@ -19,2 +19,13 @@ # node-mysql-wrap-production

let pool = mysql.createPool(config.mysql);
that.sql = createNodeMySQL(pool);
```javascript
var sql = createNodeMySQL(mysql.createPool({
host: config.mysql.host,
user: config.mysql.user,
password: config.mysql.password,
}));
```
Pool Clusters with read write seperation is also supported

@@ -57,2 +68,4 @@ ```javascript

##Methods

@@ -59,0 +72,0 @@

@@ -218,9 +218,12 @@ 'use strict';

self.save = function (table, rowRaw) {
self.save = function (table, rowOrRows) {
let rows = _.isArray(rowOrRows) ? rowOrRows : [rowOrRows];
let prepareSaveRows = function () {
let insertRow = prepareInsertRows(rowRaw);
let insertRow = prepareInsertRows(rows);
let setValues = [];
let setSQL = _.map(rowRaw, function (val, key) {
setValues.push(key, val);
return '?? = ?';
let setSQL = _.map(_.first(rows), function (val, key) {
setValues.push(key, key);
return '?? = VALUES(??)';
}).join(', ');

@@ -227,0 +230,0 @@

@@ -13,26 +13,12 @@ 'use strict';

let that = this;
that.poolCluster = mysql.createPoolCluster({
canRetry: true,
removeNodeErrorCount: 1,
restoreNodeTimeout: 20000,
defaultSelector: 'RR'
});
that.poolCluster.add('MASTER', config.mysql);
that.poolCluster.add('SLAVE_1', _.extend(config.mysql, { port: 3307}));
that.stripIds = data => _.isArray(data) ?
_.map(data, that.stripIds) : _.omit(data, 'id');
that.sql = createNodeMySQL(that.poolCluster, {
replication: {
write: 'MASTER',
read: 'SLAVE_*'
}
let pool = mysql.createPool(config.mysql);
that.sql = createNodeMySQL(pool);
pool.getConnection(function (err, conn) {
that.masterConn = conn;
done();
});
that.poolCluster.getConnection(
'MASTER',
function (err, conn) {
that.masterConn = conn;
done();
}
);
});

@@ -58,9 +44,4 @@

'VALUES ("bar")',
function () {
// set timeout is necessary since it takes
// a little time for writes to master to
// propogate to the slaves
setTimeout(function () {
done();
}, 20);
function (err) {
done();
}

@@ -458,2 +439,25 @@ );

});
it('should handle bulk save', function (done) {
let that = this;
let rows = [
{ unique: 'a', field: 'edit-a' },
{ unique: 'b', field: 'edit-b' },
{ unique: 'd', field: 'new-field' }
];
that.sql.save('table', rows)
.then(function () {
that.masterConn.query(
'SELECT * FROM `table`',
function (err, res) {
chai.assert.sameDeepMembers(
that.stripIds(res),
that.stripIds(rows.concat([that.c]))
);
done();
}
);
})
.done();
});
});

@@ -460,0 +464,0 @@

Sorry, the diff of this file is not supported yet

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