I have a table called votes which stores votes made by users. The table stores the user_id, a group_id, a timestamp of the vote and the item_id for what the user voted for:
votes
------------
user_id
group_id
item_id
vote_datetime
The way I setup the table means that users can vote for the same item multiple times, and the only difference between these votes would be the datetime.
My question is how can I select all elements of that table with the same group_id, but with the condition to count only one vote per user for an item? thanks in advance carl
EDIT: Here is a start.
select all elements for group_id equal 1
allvotes = models.votes.query.filter_by(group_id=1).all()
so how would I modify this to make sure that users can't vote twice for the same item?