Bellow是我拥有的表结构的概述
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
目的:所有用户都可以查看彼此的帖子。现在,当用户喜欢某人的帖子时,该帖子的 likeCounter 应该增加 1。
问题:我找不到更新likeCounter 的持久方法。唯一有效的方法是
1) 检索帖子
2)做likeCount++
3) 保存帖子
如您所见,存在数据持久性问题。如果您能向我展示一个可行的代码,请帮助它会更好。虽然我发现了这个,但我不知道如何实现它