2013-09-11 23:36:55 -04:00
|
|
|
module.exports = function(knex) {
|
|
|
|
|
2013-09-12 13:30:47 -04:00
|
|
|
describe('Aggregate', function() {
|
2013-09-11 23:36:55 -04:00
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
it('has a sum', function() {
|
2013-09-11 23:36:55 -04:00
|
|
|
|
2013-09-12 13:30:47 -04:00
|
|
|
return knex('accounts').logMe().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 13:30:47 -04:00
|
|
|
return knex('accounts').logMe().count('id');
|
2013-09-11 23:36:55 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2013-09-12 01:00:44 -04:00
|
|
|
it("support the groupBy function", function() {
|
|
|
|
|
2013-09-13 18:48:28 -04:00
|
|
|
return knex('accounts').logMe().count('id').groupBy('logins').then(function() {
|
|
|
|
return knex('accounts').logMe().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
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
};
|