adonis count with where 1

adonis count with where

await UserRating.query().where('user_id', '=', 42).avg('rating')

Here is what the above code is Doing:
1. We’re querying the UserRating model for all rows where the user_id column is equal to 42.
2. We’re then using the avg() method to calculate the average rating for all rows that match the query.
3. Finally, we’re awaiting the result of the query.

Similar Posts