This will require 2 separate junction tables, one for upvotesand one for downvotes.
The junction will be useruuid + postuuid.
When upvoting or downvoting the uuid belonging to the user that initiated the action will be added to the respective junction table.
When calculating the votes, just use the count diesel DSL method.
The belongingTo/groupBy diesel DSL will make it efficient to get these for multiple posts at once.
Return both the upvotes and downvotes and let the client determine how to display an aggregate.
This will require 2 separate junction tables, one for upvotesand one for downvotes.
The junction will be useruuid + postuuid. When upvoting or downvoting the uuid belonging to the user that initiated the action will be added to the respective junction table. When calculating the votes, just use the
count
diesel DSL method. The belongingTo/groupBy diesel DSL will make it efficient to get these for multiple posts at once.Return both the upvotes and downvotes and let the client determine how to display an aggregate.