> ## Documentation Index
> Fetch the complete documentation index at: https://nestjs-query.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# v0.24.x to v0.25.x

## Aggregate Queries Return Arrays[​](#aggregate-queries-return-arrays "Direct link to Aggregate Queries Return Arrays")

In versions prior to `v0.24.0` aggregate queries returned a single response with just the aggregated values. In `v0.25.0` we have introduced a new `groupBy` option that requires aggregates to return arrays.

When using aggregates without the groupBy the response will always contain a single record with your aggregated values. If you specify a `groupBy` you will get a response with a distinct group and the corresponding aggregated values.

Given the following query

```graphql theme={null}
{
  todoItemAggregate {
    count {
      id
    }
    sum {
      id
    }
    avg {
      id
    }
    min {
      id
      title
      created
    }
    max {
      id
      title
      created
    }
  }
}
```

### Old[​](#old "Direct link to Old")

The old response would look like

```json theme={null}
{
  "data": {
    "todoItemAggregate": {
      "count": {
        "id": 5
      },
      "sum": {
        "id": 15
      },
      "avg": {
        "id": 3
      },
      "min": {
        "id": "1",
        "title": "Add Todo Item Resolver",
        "created": "2021-03-29T06:51:26.061Z"
      },
      "max": {
        "id": "5",
        "title": "How to create item With Sub Tasks",
        "created": "2021-03-29T06:51:26.061Z"
      }
    }
  }
}
```

### New[​](#new "Direct link to New")

The new response will look like

```json theme={null}
{
  "data": {
    "todoItemAggregate": [
      {
        "count": {
          "id": 5
        },
        "sum": {
          "id": 15
        },
        "avg": {
          "id": 3
        },
        "min": {
          "id": "1",
          "title": "Add Todo Item Resolver",
          "created": "2021-03-29T06:51:26.061Z"
        },
        "max": {
          "id": "5",
          "title": "How to create item With Sub Tasks",
          "created": "2021-03-29T06:51:26.061Z"
        }
      }
    ]
  }
}
```

## New Aggregate GroupBy[​](#new-aggregate-groupby "Direct link to New Aggregate GroupBy")

The new response format really shines when using the `groupBy` query

Given the following aggregate grouping on `completed`

```graphql theme={null}
{
  todoItemAggregate {
    groupBy {
      completed
    }
    count {
      id
    }
    sum {
      id
    }
    avg {
      id
    }
    min {
      id
      title
      created
    }
    max {
      id
      title
      created
    }
  }
}
```

You'll get the following response with record for each distinct group

```json theme={null}
{
  "data": {
    "todoItemAggregate": [
      {
        "groupBy": {
          "completed": false
        },
        "count": {
          "id": 4
        },
        "sum": {
          "id": 14
        },
        "avg": {
          "id": 3.5
        },
        "min": {
          "id": "2",
          "title": "Add Todo Item Resolver",
          "created": "2021-03-29T06:51:26.061Z"
        },
        "max": {
          "id": "5",
          "title": "How to create item With Sub Tasks",
          "created": "2021-03-29T06:51:26.061Z"
        }
      },
      {
        "groupBy": {
          "completed": true
        },
        "count": {
          "id": 1
        },
        "sum": {
          "id": 1
        },
        "avg": {
          "id": 1
        },
        "min": {
          "id": "1",
          "title": "Create Nest App",
          "created": "2021-03-29T06:51:26.061Z"
        },
        "max": {
          "id": "1",
          "title": "Create Nest App",
          "created": "2021-03-29T06:51:26.061Z"
        }
      }
    ]
  }
}
```

[Edit this page](https://github.com/tripss/nestjs-query/edit/master/docs/migration-guides/v0.24.x-to-v0.25.x)
