Comparing version 0.5.5 to 0.5.6
@@ -1,2 +0,2 @@ | ||
// Knex.js 0.5.5 | ||
// Knex.js 0.5.6 | ||
// -------------- | ||
@@ -91,3 +91,3 @@ | ||
// Keep in sync with package.json | ||
knex.VERSION = '0.5.5'; | ||
knex.VERSION = '0.5.6'; | ||
@@ -94,0 +94,0 @@ // Runs a new transaction, taking a container and returning a promise |
@@ -375,2 +375,7 @@ // Builder | ||
// Retrieve the avg of the values of a given column. | ||
avg: function(column) { | ||
return this._aggregate('avg', column); | ||
}, | ||
// Increments a column's value by the specified amount. | ||
@@ -514,6 +519,16 @@ increment: function(column, amount) { | ||
push.apply(this.bindings, query.bindings); | ||
} | ||
}, | ||
// Helper to pull a single column from each result and return array | ||
pluck: function (column) { | ||
if (!column) { | ||
throw new Error('You must specify a column to pluck.'); | ||
} | ||
return this.column(column).then(function (results) { | ||
return _.pluck(results, column); | ||
}); | ||
}, | ||
}); | ||
exports.Builder = Builder; |
{ | ||
"name": "knex", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "A query builder for Postgres, MySQL and SQLite3, designed to be flexible, portable, and fun to use.", | ||
@@ -29,3 +29,3 @@ "main": "knex.js", | ||
"mkdirp": "~0.3.5", | ||
"bluebird": "~0.11.5-0", | ||
"bluebird": "~1.0.0", | ||
"colors": "~0.6.2", | ||
@@ -32,0 +32,0 @@ "lodash": ">=2.4.0" |
@@ -11,2 +11,8 @@ module.exports = function(knex) { | ||
it('has an avg', function() { | ||
return knex('accounts').logMe().avg('logins'); | ||
}); | ||
it('has a count', function() { | ||
@@ -13,0 +19,0 @@ |
@@ -25,2 +25,25 @@ module.exports = { | ||
}, | ||
'has an avg': { | ||
mysql: { | ||
bindings: [], | ||
sql: 'select avg(`logins`) from `accounts`', | ||
result: [{ | ||
'avg(`logins`)': 1.6667 | ||
}] | ||
}, | ||
postgresql: { | ||
bindings: [], | ||
sql: 'select avg("logins") from "accounts"', | ||
result: [{ | ||
avg: '1.6666666666666667' | ||
}] | ||
}, | ||
sqlite3: { | ||
bindings: [], | ||
sql: 'select avg("logins") from "accounts"', | ||
result: [{ | ||
'avg("logins")': 1.6666666666666667 | ||
}] | ||
} | ||
}, | ||
'has a count': { | ||
@@ -27,0 +50,0 @@ mysql: { |
@@ -435,2 +435,8 @@ var _ = require('lodash'); | ||
describe('pluck', function() { | ||
it('should pluck a defined key from the result set'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
249888
6480
+ Addedbluebird@1.0.8(transitive)
- Removedbluebird@0.11.6(transitive)
Updatedbluebird@~1.0.0