Below is an overview of the table structure I have:
Table data
----------------------------------
- User -
----------------------------------
| objectId | name | password |
----------------------------------
| z12ttttt | Matt | hidden |
| z12zzzzz | Jobs | hidden |
| z12bbbbb | Ballu | hidden |
| z12aaaaa | Stephin | hidden |
----------------------------------
--------------------------------------------------
- Post -
--------------------------------------------------
| objectId | post | postBy | likesCounter |
--------------------------------------------------
| blabla | Head Pain | z12ttttt | 0 |
| blab12 | Back Pain | z12ttttt | 0 |
| blab23 | Sleepy | z12ttttt | 0 |
| blab90 | Head Pain | z12zzzzz | 0 |
| blab90 | lets Dance| z12bbbbb | 0 |
| blab90 | lets jump | z12aaaaa | 0 |
--------------------------------------------------
//postBy has a 1 to 1 relationship with User table
Aim: All users can view each other's posts. Now, whenever a user likes someone's post, that post's likeCounter should increase by 1.
Problem: I am unable to find a persistent way to update the likeCounter. The only method that is working is:
1) Retrieve Post
2) Increment likeCounter++
3) Save Post
As you can see, there is a data persistency issue. Please help. It would be better if you could provide me with some workable code. Although I have come across this resource, I am having difficulty implementing it.