New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

anydb-sql

Package Overview
Dependencies
Maintainers
3
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anydb-sql - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0

52

anydb-sql.js

@@ -19,2 +19,3 @@ var anyDB = require('any-db');

var P = require('bluebird');

@@ -29,2 +30,15 @@ function extractDialect(adr) {

function wrapQuery(ctx) {
var oldquery = ctx.query;
var pquery = P.promisify(ctx.query, ctx);
ctx.query = function(q, args, cb) {
if (typeof(args) === 'function') {
cb = args;
args = undefined;
}
return pquery(q, args).nodeify(cb);
}
return ctx;
}
module.exports = function (opt) {

@@ -51,2 +65,3 @@

}
wrapQuery(pool);
}

@@ -113,14 +128,13 @@

var query = self.toQuery(); // {text, params}
if (!fn)
return where.query(query.text, query.values);
else
return where.query(query.text, query.values, function (err, res) {
if (err) {
err = new Error(err);
err.message = err.message.substr('Error '.length)
+ ' in query `' + query.text
+ '` with params ' + JSON.stringify(query.values);
}
fn(err, res && res.rows ? grouper.process(res.rows) : null);
});
return where.query(query.text, query.values)
.then(function (res) {
return res && res.rows ? grouper.process(res.rows) : null;
}, function(err) {
err = new Error(err);
err.message = err.message.substr('Error '.length)
+ ' in query `' + query.text
+ '` with params ' + JSON.stringify(query.values);
throw err;
}).nodeify(fn);
};

@@ -133,5 +147,5 @@ extQuery.allWithin = extQuery.execWithin;

extQuery.getWithin = function(where, fn) {
return self.execWithin(where, function getSingleResult(err, rows) {
return fn(err, rows && rows.length ? rows[0] : null);
});
return self.execWithin(where).then(function(rows) {
return rows && rows.length ? rows[0] : null;
}).nodeify(fn);
}

@@ -210,3 +224,2 @@

else {
console.log(table);
return all;

@@ -231,2 +244,3 @@ }

}
console.log('tx savepoint');
return {

@@ -237,5 +251,9 @@ rollback: restore,

release: release,
query: tx.query.bind(tx)
query: function() {
console.log('sp query');
return tx.query.apply(tx, arguments);
}
};
};
wrapQuery(tx);
return tx;

@@ -242,0 +260,0 @@ }

{
"name": "anydb-sql",
"version": "0.3.3",
"version": "0.4.0",
"description": "anydb-sql combines node-anydb and node-sql into a single package full of awesomeness.",

@@ -29,3 +29,4 @@ "main": "anydb-sql.js",

"any-db": "~0.6.0",
"lodash": "~1.3.1"
"lodash": "~1.3.1",
"bluebird": "~0.7.10-1"
},

@@ -32,0 +33,0 @@ "devDependencies": {

@@ -65,4 +65,4 @@ # anydb-sql

If you omit the callback from a querying method, an eventemitter will be
returned instead (like in anydb).
If you omit the callback from a querying method, a promise will be
returned instead.

@@ -69,0 +69,0 @@ Use regular node-sql queries then chain one of the querying methods at the

@@ -58,2 +58,9 @@ var test = require('tap').test;

t.test('where get .then', function(t) {
user.where({id: 1}).get().then(function(user) {
t.deepEquals(user, {id: 1, name: 'test'});
t.end();
});
});
t.test('insert transaction', function(t) {

@@ -96,6 +103,4 @@ db.begin(function(err, tx){

.select(userx.id);
//console.log(query.toQuery())
query.get(function(err, res) {
//console.log(err, res);
t.equals(res.id, 1, 'user.id is 1');

@@ -102,0 +107,0 @@ t.end();

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