Skip to content

Commit

Permalink
optimize count api
Browse files Browse the repository at this point in the history
  • Loading branch information
ujjwalguptaofficial committed Jul 27, 2020
1 parent 6d83202 commit 068725b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/grammar/count.pegjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
countQuery = COUNT _ ("*"_)? FROM _ table:tableName _* where:whereQry? _*
option:(distinct/groupBy)* {
var distinct = false;
var groupBy = null;
option.forEach(val=>{
options:(distinct/groupBy)* {
const option = {};
options.forEach(val=>{
var key = Object.keys(val)[0];
switch(key){
case 'distinct':
distinct = val[key]; break;
option.distinct = val[key]; break;
case 'groupBy':
groupBy = val[key]; break;
option.groupBy = val[key]; break;
}
});
return {
api:'count',
data:{
from:table,
where:where,
distinct : distinct,
groupBy:groupBy
...option
}
}
}

0 comments on commit 068725b

Please sign in to comment.