Skip to content

Commit

Permalink
reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
agershun committed Dec 24, 2014
1 parent 94de118 commit c5028d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog


### 0.0.35 (23.12.2014 - .12.2014)

* REDUCE Aggregator

### 0.0.35 (14.12.2014 - 22.12.2014)

* Added [?] array conversion
Expand Down
10 changes: 10 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@

## Next Versions

http://stackoverflow.com/questions/25677207/count-total-with-two-criterias-using-lodash/27634849#27634849
// User-defined aggregator to concat arrays
alasql.aggr.CONCAT = function(v,s) {
return (s||[]).concat(v);
};

SELECT VALUE CONCAT(_)

http://stackoverflow.com/questions/25047463/group-by-and-sum-using-underscore-lodash/27634325#27634325
SELECT INDEX platformId, SUM(payout) AS payout, SUM(numOfPeople) AS numOfPeople FROM ? GROUP BY platformId;

alasql("SELECT RECORDSET * FROM XLSX(?)",[recordset]);
alasql("SELECT KEY a, ARRAY(_) FROM ?",[data]); == _.groupBy(data,"a"); like Lodash
Expand Down
10 changes: 9 additions & 1 deletion test/test185.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ describe('Test 185 - IN Expression', function() {
it("1. REDUCE Aggregator", function(done) {
var data = [{a:[1,2,3,4,1,2,2,3],b:1},{a:[10],b:10}];
alasql.aggr.Summa = function(v,s){
// console.log(v,s);
return v+(s|0);
};
var res = alasql('SELECT VALUE Summa(b) FROM ?',[data]);
assert(res==11);

alasql.aggr.Concat = function(v,s){
if(typeof s == 'undefined') return v;
return s.concat(v);
};
var a1 = [{a:1,b:[1,2,3]},{a:2,b:[4,5]},{a:1,b:[1,2,3,4]}];
var res = alasql('SELECT a,Concat(b),COUNT(*) FROM ? GROUP BY a',[a1]);

console.log(res);
done();
});
Expand Down

0 comments on commit c5028d7

Please sign in to comment.