Hi,
From the below results I’m trying to add the both
‘rating’ field key values, 15 + 50 together, totalling 65
‘count’ field key values, 3 + 10 together, totalling 13
I appreciate I could run separate queries but I’m trying to expand my knowledge and see how this would be possible.
This is the code I’m using to get one item to show
async function categoryRatings(){
let stats = await wixData.query('Review-Stats').contains('category', thisCourse.title).find();
if (stats) {
let avgRating = (Math.round(stats.rating * 10 / stats.count) / 10);
let percentRecommended = Math.round(stats.recommended / stats.count * 100);
let ratings = $w('#ratingsDisplay1');
ratings.rating = avgRating;
ratings.numRatings = stats.count;
$w('#ratingsDisplay1').show();
console.log('Ratings results', stats)
} else {
console.log('No Result')
$w('#ratingsDisplay1').rating = null;
}
}
Thank you