magla
var t = db.products.find();
t.forEach(function( aRow ) {
var counter = 0;
aRow.reviews.forEach( function( aReview ){
if (aReview.score == 5.0){ // promijeni ‘== 5.0’ ovisno o ocjeni
counter = counter + 1;
}
} )
db.products.update(
{ id: aRow.id },
{ “$set”: { “reviewStats.reviewScoreDistrib.5”: counter } } // promijeni ‘reviewScoreDistrib.5’ ovisno o ocjeni
);
});
ovo je radilo, ali nije nesto prelijepo haha