2013-09-11 23:36:55 -04:00
|
|
|
var when = require("when");
|
|
|
|
|
|
|
|
module.exports = function(knex) {
|
|
|
|
|
|
|
|
describe('aggregate', function() {
|
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
it('has a sum', function() {
|
2013-09-11 23:36:55 -04:00
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
return knex('accounts').sum('logins');
|
2013-09-11 23:36:55 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
it('has a count', function() {
|
2013-09-11 23:36:55 -04:00
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
return knex('accounts').count('id');
|
2013-09-11 23:36:55 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
it("support the groupBy function", function() {
|
|
|
|
|
|
|
|
return when.all([
|
|
|
|
knex('accounts').count('id').groupBy('logins'),
|
|
|
|
knex('accounts').count('id').groupBy('first_name')
|
|
|
|
]);
|
2013-09-11 23:36:55 -04:00
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
});
|
2013-09-11 23:36:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
};
|