Getting Counts on Relations with Prisma Client

preview_player
Показать описание
New at Prisma 2.20 is the ability to get the counts of related fields. This is useful for cases where you'd like to get the total number of records for a model through a relation.

For example, you may want to get Author records and the total number of Posts that each other has. This is easy at Prisma 2.20 with the selectRelationCount feature flag.

In this video, Ryan Chenkie demonstrates how to use the new relation count feature.

------------------------
Next:
-----------------------
📚 Resources:

✅ Learn more about Prisma:

------------------------
💬 Connect with Prisma:
Рекомендации по теме
Комментарии
Автор

How performant is this ? especially in a social media website where the count gets queried a ton of times

ahmedosama
Автор

Hallo! Nice feature! How to filter though before counting?

mariaarkadieff
Автор

Using your example, how can I query all authors where post count is greater than zero?

cb
Автор

Hi there . I try to input the previewerFeatures but don't work because says that is deprecated. How do you do ? my version is 3.10.0

amirawebsystems
Автор

Why do something on start EVERYTIME instead of calculatting some fields like this on update/create/delete ONCE?

ПавелШлыков-мч
Автор

It`s possible to populate using the FK, like mongodb ?

dev.caixeiroviajante
Автор

How about _count: { select: post: { where … }}

ZixPainGamer
Автор

can you then order by the related aggregate value?

grubstarstar
Автор

how to get users data if the post count is more than 2

rohanparange
Автор

We are waiting for mongodb to be supported

innovafrique
visit shbcf.ru