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