Course

Aggregates

What are aggregates? Aggregates are a way to calculate statistics on a set of records. In this lesson, we'll learn how to use Prisma to calculate aggregates such as:

- The number of records in a table.

- The average value of a field in a table.

- The sum of a field in a table.

- The minimum value of a field in a table.

- The maximum value of a field in a table.

Insight

Aggregates are sometimes considered expensive operations, especially on large datasets. Use them carefully. It can sometimes be better to calculate aggregates outside of a query with regular javascript. This will depend on your specific use case and the size of your data set.

If you find yourself needing to calculate aggregates frequently, you may want to consider denormalizing your data or calculating the aggregates outside of a query.

If you followed the previous lessons, you should have a Prisma client set up and a database with some data. You'll have a whole project available to begin experimenting with more complex queries.

In the following lessons, we'll learn how to use Prisma to calculate these aggregates, and we'll be using examples related to the project we've already built. You can take it upon yourself to run these, and experiment with integrating them into your project!

0 Comments

"Please login to view comments"

glass-bbok

Join the Conversation!

Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.

Upgrade your account
tick-guideNext Lesson

Aggregates - Count