Comparing version 1.1.0 to 1.1.1
@@ -13,2 +13,10 @@ # Tedium Changelog | ||
### 1.1.x | ||
* 1.1.1 | ||
* Make using methods return the result from the scope function. [b2a2e22](https://github.com/bretcope/tedium/commit/b2a2e2273aa6bc83ab3cd9b9c3395ba5899c6969) | ||
* Added optional context argument to `using` methods. [#1](https://github.com/bretcope/tedium/pull/1) | ||
* 1.1.0 | ||
* Support multiple result sets. [e06b256](https://github.com/bretcope/tedium/commit/e06b25626160077267c79aefe0396b7a690ed783) | ||
### 1.0.x | ||
@@ -15,0 +23,0 @@ |
@@ -54,32 +54,32 @@ "use strict"; | ||
} | ||
var colNames = []; | ||
var recordsets = []; | ||
var recordset = []; | ||
req.on('columnMetadata', function (metadata) | ||
{ | ||
colNames = columnNamesFromMetadata(metadata); | ||
}); | ||
function done(rowCount, more) | ||
{ | ||
if (colNames.length === 0) return; | ||
recordsets.push(recordset); | ||
recordset = []; | ||
colNames = []; | ||
} | ||
req.on('done', done); | ||
req.on('doneInProc', done); | ||
req.on('row', function (columns) | ||
{ | ||
var row = {}; | ||
for (var i = 0, l = columns.length; i < l; ++i) | ||
row[colNames[i]] = columns[i].value; | ||
recordset.push(row); | ||
}); | ||
var colNames = []; | ||
var recordsets = []; | ||
var recordset = []; | ||
req.on('columnMetadata', function (metadata) | ||
{ | ||
colNames = columnNamesFromMetadata(metadata); | ||
}); | ||
function done(rowCount, more) | ||
{ | ||
if (colNames.length === 0) return; | ||
recordsets.push(recordset); | ||
recordset = []; | ||
colNames = []; | ||
} | ||
req.on('done', done); | ||
req.on('doneInProc', done); | ||
req.on('row', function (columns) | ||
{ | ||
var row = {}; | ||
for (var i = 0, l = columns.length; i < l; ++i) | ||
row[colNames[i]] = columns[i].value; | ||
recordset.push(row); | ||
}); | ||
if (options.batch) | ||
@@ -96,3 +96,3 @@ this.tediousConnection.execSqlBatch(req); | ||
}; | ||
this.lastActivity = Date.now(); | ||
@@ -107,11 +107,11 @@ if (sqlResult instanceof Array) | ||
result.rows = options.multiple | ||
? recordsets | ||
: recordsets[0]; | ||
result.rows = options.multiple | ||
? recordsets | ||
: recordsets[0]; | ||
} | ||
return result; | ||
}; | ||
TdmConnection.prototype.usingTransaction = function * (isolationLevel, name, scope) | ||
TdmConnection.prototype.usingTransaction = function * (isolationLevel, name, scope, ctx) | ||
{ | ||
@@ -122,2 +122,3 @@ if (typeof scope !== 'function') | ||
{ | ||
ctx = scope; | ||
scope = name; | ||
@@ -128,2 +129,3 @@ name = undefined; | ||
{ | ||
ctx = name; | ||
scope = isolationLevel; | ||
@@ -138,6 +140,7 @@ name = undefined; | ||
let error = null; | ||
let result; | ||
try | ||
{ | ||
yield scope(tran); | ||
result = yield scope.call(ctx, tran); | ||
} | ||
@@ -154,2 +157,4 @@ catch (ex) | ||
throw error; | ||
return result; | ||
}; | ||
@@ -159,6 +164,6 @@ | ||
{ | ||
var names = new Array(metadata.length); | ||
for (var i = 0, l = metadata.length; i < l; ++i) | ||
names[i] = metadata[i].colName; | ||
return names; | ||
var names = new Array(metadata.length); | ||
for (var i = 0, l = metadata.length; i < l; ++i) | ||
names[i] = metadata[i].colName; | ||
return names; | ||
} |
@@ -149,3 +149,3 @@ "use strict"; | ||
TdmConnectionPool.prototype.using = function * (scope) | ||
TdmConnectionPool.prototype.using = function * (scope, ctx) | ||
{ | ||
@@ -155,4 +155,5 @@ var c = yield this.acquire(); | ||
{ | ||
yield scope(c); | ||
var result = yield scope.call(ctx, c); | ||
this.release(c); | ||
return result; | ||
} | ||
@@ -167,8 +168,8 @@ catch (ex) | ||
TdmConnectionPool.prototype.usingTransaction = function * (isolationLevel, name, scope) | ||
TdmConnectionPool.prototype.usingTransaction = function * (isolationLevel, name, scope, ctx) | ||
{ | ||
yield this.using(/**@param db {TdmConnection}*/function * (db) | ||
return yield this.using(/**@param db {TdmConnection}*/function * (db) | ||
{ | ||
yield db.usingTransaction(isolationLevel, name, scope); | ||
return yield db.usingTransaction(isolationLevel, name, scope, ctx); | ||
}); | ||
}; |
{ | ||
"name": "tedium", | ||
"description": "A generator-based wrapper for Tedious to make it easier to work with.", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": "Bret Copeland <bret@atlantisflight.org>", | ||
@@ -6,0 +6,0 @@ "main": "./lib/Tedium.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
30955
11
609
0