@@ -272,6 +272,54 @@ describe('crud-with-options', function() {
272272 User . find ( { limit : 3 } ) ;
273273 } ) ;
274274
275+ it ( 'should allow filter with groupBy, count, max, min, sum & avg' , function ( done ) {
276+ User . find ( {
277+ groupBy : [ 'vip' ] ,
278+ count : 'vip' ,
279+ max : 'id' ,
280+ min : 'id' ,
281+ sum : 'id' ,
282+ avg : 'id' ,
283+ } , options , function ( err , users ) {
284+ should . not . exist ( err ) ;
285+ should . exist ( users ) ;
286+ users . length . should . be . above ( 0 ) ;
287+ users . forEach ( user => {
288+ user . should . have . property ( 'count' , user . count ) ;
289+ user . should . have . property ( 'max' ) ;
290+ user . should . have . property ( 'min' ) ;
291+ user . should . have . property ( 'sum' ) ;
292+ user . should . have . property ( 'avg' ) ;
293+ } ) ;
294+ done ( ) ;
295+ } ) ;
296+ } ) ;
297+
298+ it ( 'should allow filter with groupBy, aggregate methods and other filters' , function ( done ) {
299+ User . find ( {
300+ groupBy : [ 'vip' ] ,
301+ count : 'vip' ,
302+ max : 'id' ,
303+ min : 'id' ,
304+ sum : 'id' ,
305+ avg : 'id' ,
306+ limit : 1 ,
307+ fields : [ 'name' , 'id' ] ,
308+ } , options , function ( err , users ) {
309+ should . not . exist ( err ) ;
310+ should . exist ( users ) ;
311+ users . length . should . be . equal ( 1 ) ;
312+ users . forEach ( user => {
313+ user . should . have . property ( 'count' , user . count ) ;
314+ user . should . have . property ( 'max' ) ;
315+ user . should . have . property ( 'min' ) ;
316+ user . should . have . property ( 'sum' ) ;
317+ user . should . have . property ( 'avg' ) ;
318+ } ) ;
319+ done ( ) ;
320+ } ) ;
321+ } ) ;
322+
275323 it ( 'should skip trailing undefined args' , function ( done ) {
276324 User . find ( { limit : 3 } , function ( err , users ) {
277325 should . exists ( users ) ;
0 commit comments