Ibad Shaikh
12/07/2021, 1:49 PMuser_id
which is linked to user model.
• There is a rating model which contains user_id
& post_id
& value
which stores the rating given on a specific post by a user.
• How could I get the average rating. I tried but couldn't found a solution for it.
Thanking in advance :)Franco Roura
12/07/2021, 2:41 PMIbad Shaikh
12/10/2021, 8:48 PMIbad Shaikh
12/11/2021, 11:04 AMconst _average_ = _await prisma.rating.groupBy_({
_by_:
['user_id'],
_where_:
{
_post_:
{
_user_id_: _Number_(_req.params.userId_),
_ _},
_ _},
__avg_:
{
_value_: _true_,
_ _},
_ _})
This query helped me to do so.