Dear All,
Consider implementing Facebook Like. My case is:
I have mobile app and synch gateway to synch documents.
The mobile app gets pushed new NewsArticles. The user needs to vote them, if they like.
I thought of these options to implement it:
-
I will create a document called NewsArticleLikes to keep the counter of likes for each NewsArticleLikes {“news_article”:“NewsArticle_1”, “owner”:"sdsd@dd.com", “counter”,1); Do not allow to synch the NewsArticleLikes from server to mobiles.Instead, mobile client fetch the latest counter value for the specific NewsArticle using REST API over the server. Then update the counter using REST PUT.
Question A) I think, in this case, it will just overwrite the counter value with my update. I will loose updates from others?
Question B) What if I synch the NewsArticleLikes to all mobile clients and perform the updates there using CAS feature to manage concurrent updates. Then push the NewsArticleLikes to server thru Synch Gateway. I think, that would not work because of the conflicts. -
I will create a new NewsArticleLikes document for each voting for an article using the REST API on the server. I will not synch those documents back to mobile app. And then I will count the number of NewsArticleLikes documents for a specific user and article. Then, calculate the total number of votes in the view. That option will create a lot of documents on the server and the mobile client has to make a REST call to server for each NewsArticle displayed which is bad for performance. I do not want to push all NewsArticleLikes documents from server to mobile as there will be thousands of documents consuming space in the mobile storage.
What is the proper way of doing this, if you consider the number of users are high (there will be update conflicts a lot) and performance is important as well?
Thx,
CK