Skip to content

Commit

Permalink
Merged pull request #6 from karb/patch-1.
Browse files Browse the repository at this point in the history
added groupBy function
  • Loading branch information
xavierlacot committed Apr 28, 2011
2 parents 8cb13db + 80b55d3 commit e53bdd2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions joli.js
Expand Up @@ -494,6 +494,10 @@ joli.query.prototype = {
query += ' where ' + this.data.where;
}

if (this.data.groupBy) {
query += ' group by ' + this.data.groupBy.join(', ');
}

if (this.data.order.length > 0) {
query += ' order by ' + this.data.order.join(', ');
}
Expand All @@ -505,6 +509,15 @@ joli.query.prototype = {
return query;
},

groupBy: function(group) {
if ('string' == joli.getType(group)) {
group = [group];
}

this.data.groupBy = group;
return this;
},

hydrate: function(rows) {
var result = [];

Expand Down

0 comments on commit e53bdd2

Please sign in to comment.