I currently have a list of restaurants similar to how Yelp works that have ratings from 1-5 and a total number of ratings. When showing the restaurants to my users, I want to sort by a weighted combination of ratings and reviews so that a restaurant with 1 5 star rating doesn't outrank a restaurant with 20 5 star ratings and 10 4 star ratings.
I want to use something like this answer: https://stackoverflow.com/a/1411268/7754241, but since the mean vote changes everytime a new restaurant is added or a new review is added, I am unsure how to do this dynamically.
Is this possible to do this within a db.find().sort() MongoDB query?