@@ -321,6 +321,71 @@ describe('universe query', function() {
321321 } )
322322 } )
323323
324+ it ( 'can query using the valueList aggregation' , function ( ) {
325+ var res
326+ return u . then ( function ( u ) {
327+ return u . query ( {
328+ groupBy : 'type' ,
329+ select : {
330+ $valueList : 'total' ,
331+ }
332+ } )
333+ } )
334+ . then ( function ( r ) {
335+ res = r
336+ expect ( res . data ) . to . deep . equal ( [
337+ { key : 'cash' , value : { valueList : [ 100 , 200 ] } } ,
338+ { key : 'tab' , value : { valueList : [ 90 , 90 , 90 , 90 , 90 , 90 , 190 , 190 ] } } ,
339+ { key : 'visa' , value : { valueList : [ 200 , 300 , 50000 ] } } ] )
340+ } )
341+ } )
342+
343+ it ( 'can query using the dataList aggregation' , function ( ) {
344+ var res
345+ return u . then ( function ( u ) {
346+ return u . query ( {
347+ groupBy : 'type' ,
348+ select : {
349+ $dataList : 'total' ,
350+ }
351+ } )
352+ } )
353+ . then ( function ( r ) {
354+ res = r
355+ expect ( res . data ) . to . deep . equal ( [ {
356+ "key" : "cash" ,
357+ "value" : {
358+ "dataList" : [
359+ { "date" : "2011-11-14T16:54:06Z" , "quantity" : 1 , "total" : 100 , "tip" : 0 , "type" : "cash" , "productIDs" : [ "001" , "002" , "003" , "004" , "005" ] } ,
360+ { "date" : "2011-11-14T17:25:45Z" , "quantity" : 2 , "total" : 200 , "tip" : 0 , "type" : "cash" , "productIDs" : [ "002" ] }
361+ ]
362+ }
363+ } , {
364+ "key" : "tab" ,
365+ "value" : {
366+ "dataList" : [
367+ { "date" : "2011-11-14T16:17:54Z" , "quantity" : 2 , "total" : 190 , "tip" : 100 , "type" : "tab" , "productIDs" : [ "001" ] } ,
368+ { "date" : "2011-11-14T16:20:19Z" , "quantity" : 2 , "total" : 190 , "tip" : 100 , "type" : "tab" , "productIDs" : [ "001" , "005" ] } ,
369+ { "date" : "2011-11-14T16:30:43Z" , "quantity" : 2 , "total" : 90 , "tip" : 0 , "type" : "tab" , "productIDs" : [ "001" , "002" ] } ,
370+ { "date" : "2011-11-14T16:48:46Z" , "quantity" : 2 , "total" : 90 , "tip" : 0 , "type" : "tab" , "productIDs" : [ "005" ] } ,
371+ { "date" : "2011-11-14T16:53:41Z" , "quantity" : 2 , "total" : 90 , "tip" : 0 , "type" : "tab" , "productIDs" : [ "001" , "004" , "005" ] } ,
372+ { "date" : "2011-11-14T16:58:03Z" , "quantity" : 2 , "total" : 90 , "tip" : 0 , "type" : "tab" , "productIDs" : [ "001" ] } ,
373+ { "date" : "2011-11-14T17:07:21Z" , "quantity" : 2 , "total" : 90 , "tip" : 0 , "type" : "tab" , "productIDs" : [ "004" , "005" ] } ,
374+ { "date" : "2011-11-14T17:22:59Z" , "quantity" : 2 , "total" : 90 , "tip" : 0 , "type" : "tab" , "productIDs" : [ "001" , "002" , "004" , "005" ] }
375+ ]
376+ }
377+ } , {
378+ "key" : "visa" ,
379+ "value" : {
380+ "dataList" : [
381+ { "date" : "2011-11-14T16:28:54Z" , "quantity" : 1 , "total" : 300 , "tip" : 200 , "type" : "visa" , "productIDs" : [ "004" , "005" ] } ,
382+ { "date" : "2011-11-14T17:29:52Z" , "quantity" : 1 , "total" : 200 , "tip" : 100 , "type" : "visa" , "productIDs" : [ "004" ] } ,
383+ { "date" : "2012-11-14T17:29:52Z" , "quantity" : 100 , "total" : 50000 , "tip" : 999 , "type" : "visa" , "productIDs" : [ "004" ] }
384+ ] }
385+ } ] )
386+ } )
387+ } )
388+
324389 // TODO: This isn't completely possible yet, reductio will need to support aliases for all aggregations first. As of this commit, it is only available on `count`
325390 // it('supports nested aliases', function(){
326391 // return u.then(function(u){
0 commit comments