I am building a site where members can vote for their favourite videos. For fairness we don’t want the members voting for the same video more than once, however they can vote for many videos if they wish. I am new to coding and would appreciate any guidance in this area. Thanks
Hi Rahbia,
If the case was like - user can only vote once - One vote for only one video, you can use
" Hookbefore insert" : This will help you
https://www.wix.com/code/reference/wix-data.Hooks.html#beforeInsert
But in that case of the ability to vote for more than one video only once , you can :
1- give an id for each video.
2- create a database " empty" with items of ( userId, videoId )
3- onClick function that checks if the current user Id is in the database, if so => check if the video id exist.
4- a) if the id doesn’t exist => add it and add the video id ( for future chech )
b) if the id exist => check if that id has been voted for (clicked video ) ID .
- This will help you with searching/inserting in database (query) : https://www.wix.com/code/reference/wix-data.html#query
GoodLuck.
Mustafa.
Can somebody help me with this
following…