在appengine上将帖子标记为已读。

huangapple go评论85阅读模式
英文:

Mark a post as read on appengine

问题

我目前正在设计一个类似于Twitter/Jaiku/Reddit的应用程序结构。基本上,它包含有投票的小帖子,并且按照得分和时间进行排序,就像Reddit一样。

我已经完成了所有这些工作,但现在我们的需求有些变化,我们需要用户能够将帖子标记为“已读”。这将使得该帖子不再出现在该用户的动态中。我可以为每个(User, Post)元组建模一个Read实体,但这将需要大量的工作来查找在该表中“不存在”的帖子。或者,我可以反转该关系,这样我就可以为每个未读帖子创建一个实体,这样更容易找到在表中“存在”的帖子... 但是,每次发布帖子时,我都需要为每个用户创建一个表中的条目。这样做不会很好地扩展。

我的问题是:我应该如何在App Engine的数据存储中建模这种负面信息?我正在使用Go运行时,如果有关运行时的答案也可以。

英文:

I'm currently designing an application similar to twitter/jaiku/reddit in structure. Basically there are small posts with upvotes and downvotes, and they are sorted by score and time like reddit.

I've gotten all of this working, but now our requirements have changed a bit, and we need the user to be able to mark a post as 'read'. This would make the post no longer show up in that user's feed. I can model this with a Read entity for each tuple of (User, Post), but this would require a lot of work to find posts which 'do not' exist in that table. Alternatively I can invert that relation so that I have one entity for each unread post, and it becomes much easier to find which posts 'do' exist in the table... But then I'd need to create an entry in this table for every single user everytime a post is made. This would not scale well.

My question is this: How would I model this sort of negative information in appengine's datastore? I'm using the go runtime if that matters, but answers for any runtime are fine.

答案1

得分: 0

这将是一个多对多的关系。这篇文章描述了如何建模不同类型的关系,包括多对多关系。唯一的问题是,我不确定你应该在用户上存储一个已读帖子的列表,还是在帖子上存储已阅读它的用户列表,因为这两个列表在不同情况下可能会变得很大。如果帖子相对私密,没有被很多人看到,你可以在帖子模型上存储一个用户键的列表。但是,如果一个帖子可能被成千上万的人看到,最好在用户上存储一个帖子列表,因为可能没有很多用户有成千上万个已读帖子。另一个选择可能是丢弃旧帖子,或者只丢弃它们的阅读状态。

英文:

This would be a many-to-many relationship. This article describes how to model different kinds of relationships, including many-to-many. The only issue is that I'm not sure weather you should store a list of read posts on the user, or a list of users who have read it, on the post, as poth lists might get large in different situations. If posts are relatively private, and not seen by many people, you could store a list of user keys on the post model. But, if one post could be seen by thousands of people, it might be better to store a list of posts on the users, as there wil probably not be many users with thousands of read posts. Another option might be to discard old posts, or just discard their read state.

huangapple
  • 本文由 发表于 2014年2月27日 06:11:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/22054544.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定