Adding values from database in Query

Hi,

I’m trying to achieve that when I query my Reviews database that it adds the total count of reviews for that ‘title’ but seem to be struggling…
This is the basic code i have started with, I have played around with some variations but none work

wixData.query("Reviews")
.eq("title", title)
.find()
.then((res) => {
let item = res.items[0]
$w('#ratingsDisplay').rating = item.rating;
$w('#ratingsDisplay').numRatings = item.count;
})

Another example that I can’t get to work

wixData.query("Reviews")
.eq("title", title)
.find()
.then((results) => {
console.log(results);                 
let items = results.items;
let value = items[i].count;  
$w('#ratingsDisplay').rating = results.rating; 
$w('#ratingsDisplay').numRatings = sumTotal;     
console.log(value);
console.log(sumTotal);
let sumTotal = 0
for (var i = 0; i < value.length; i++) {
sumTotal = sumTotal + value;
}
})

Would someone be bale to help me get the total count? Rating works fine (although it would be helpful if the result was 0 that it showed the default ‘No Reviews for this course’ text)

Many thanks in advance

Are you using or have you seen either of the two tutorials for ratings and reviews listed here?

Corvid Tutorial: Adding Ratings and Reviews to a Wix Stores Site
Corvid Tutorial: Capturing and Displaying Ratings

@givemeawhisky I have, thank you. I have been toying with them and have managed to get the array to the console but can’t get the data to populate the ratings display… the code is part of another query that populates the repeater but I need to query a separate reviews database for the ratings.

Any ideas?

Field keys are all good

wixData.query('Review-Stats')
.eq('id', ID)
.find()
.then((item)=>{
let avgRating = (Math.round(item.rating * 10 / item.count) / 10);
$w('#ratingsDisplay').rating = avgRating;
$w('#ratingsDisplay').numRatings = item.count
})