Hi everyone. I want to ask something about databas...
# orm-help
h
Hi everyone. I want to ask something about database design/flow design. Suppose my Users’
rank
depends on the number of created Posts, some other numeral values also depends on the
rank
. What is the best way to organize data? The best way I could think of, is to do all calculation on Query, so that the
rank
values will not be written to database and thus reduce chance of error. But then there seems to be TONS of database calls. What do you think?
a
Maybe create a trigger that updates the rank when you make a post?
I think better have it stored in dB, and calculate it async, that way you can also sort on user rank
h
you are right. I should call
recalculateRank()
whenever a user create a post. This can save a lot of calculation each time when fetching user data.
A long as I used the same
recalculateRank()
globally rather than calculating inside resolver, it should be safe from inconsistency