| 320 | |
| 321 | |
| 322 | async def aggregations(): |
| 323 | # count: |
| 324 | assert 2 == await Author.objects.count() |
| 325 | |
| 326 | # exists |
| 327 | assert await Book.objects.filter(title="The Hobbit").exists() |
| 328 | |
| 329 | # maximum |
| 330 | assert 1990 == await Book.objects.max(columns=["year"]) |
| 331 | |
| 332 | # minimum |
| 333 | assert 1937 == await Book.objects.min(columns=["year"]) |
| 334 | |
| 335 | # average |
| 336 | assert 1964.75 == await Book.objects.avg(columns=["year"]) |
| 337 | |
| 338 | # sum |
| 339 | assert 7859 == await Book.objects.sum(columns=["year"]) |
| 340 | |
| 341 | # to read more about aggregated functions |
| 342 | # visit: https://collerek.github.io/ormar/queries/aggregations/ |
| 343 | |
| 344 | |
| 345 | async def raw_data(): |