Skip to content

Commit

Permalink
fix aggregation examples (#322)
Browse files Browse the repository at this point in the history
The aggregation syntax used in the intro sections for aggregations was
invalid.
  • Loading branch information
kostasb authored Apr 9, 2024
1 parent 11a7692 commit 99f0171
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions 040-Data-operations/120-aggregate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,28 @@ like this:

```ts
const results = await xata.db.titles.aggregate({
"movieGenres": {
movieGenres: {
topValues: {
column: "genre",
size: 50
column: 'genre',
size: 50,
aggs: {
"byReleaseDate": {
byReleaseDate: {
dateHistogram: {
column: "releaseDate",
calendarInterval: "year",
},
aggs: {
"avgRating": {
average: {
column: "rating"
column: 'releaseDate',
calendarInterval: 'year',
aggs: {
avgRating: {
average: {
column: 'rating'
}
}
}
}
}
}
}
},
})
}
});
```

```python
Expand All @@ -59,12 +59,12 @@ results = xata.data().aggregate("titles", {
"byReleaseDate": {
"dateHistogram": {
"column": "releaseDate",
"calendarInterval": "year"
},
"aggs": {
"avgRating": {
"average": {
"column": "rating"
"calendarInterval": "year",
"aggs": {
"avgRating": {
"average": {
"column": "rating"
}
}
}
}
Expand All @@ -88,12 +88,12 @@ results = xata.data().aggregate("titles", {
"byReleaseDate": {
"dateHistogram": {
"column": "releaseDate",
"calendarInterval": "year"
},
"aggs": {
"avgRating": {
"average": {
"column": "rating"
"calendarInterval": "year",
"aggs": {
"avgRating": {
"average": {
"column": "rating"
}
}
}
}
Expand All @@ -116,27 +116,27 @@ The `/aggregate` API can be combined with top-level filters using the syntax of
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>
```ts
const results = await xata.db.titles.aggregate({
"movieGenres": {
movieGenres: {
topValues: {
column: "genre",
size: 50
column: 'genre',
size: 50,
aggs: {
"byReleaseDate": {
byReleaseDate: {
dateHistogram: {
column: "releaseDate",
calendarInterval: "year",
},
aggs: {
"avgRating": {
average: {
column: "rating"
column: 'releaseDate',
calendarInterval: 'year',
aggs: {
avgRating: {
average: {
column: 'rating'
}
}
}
}
}
}
}
},
}
},
{
"director":"Peter Jackson"
Expand All @@ -154,20 +154,20 @@ results = xata.data().aggregate("titles", {
"byReleaseDate": {
"dateHistogram": {
"column": "releaseDate",
"calendarInterval": "year"
},
"aggs": {
"avgRating": {
"average": {
"column": "rating"
"calendarInterval": "year",
"aggs": {
"avgRating": {
"average": {
"column": "rating"
}
}
}
}
}
}
}
}
}
},
"filter": {
"director":"Peter Jackson"
}
Expand All @@ -186,22 +186,22 @@ results = xata.data().aggregate("titles", {
"byReleaseDate": {
"dateHistogram": {
"column": "releaseDate",
"calendarInterval": "year"
},
"aggs": {
"avgRating": {
"average": {
"column": "rating"
"calendarInterval": "year",
"aggs": {
"avgRating": {
"average": {
"column": "rating"
}
}
}
}
}
}
}
}
}
},
"filter": {
"director":"Peter Jackson"
"director": "Peter Jackson"
}
}
```
Expand Down

0 comments on commit 99f0171

Please sign in to comment.