Yep you can do that too - just might slow things down a little on the user side with a big search.

The other thing to consider is that this update average rating function is probably a function you might want to execute from different pages in the app. In that case, it may be helpful to put that function in the backend and just call it from wherever.