使用 RavenDb 进行活动流设计 [英] Activity stream design with RavenDb

查看:36
本文介绍了使用 RavenDb 进行活动流设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与其说是技术问题,不如说是设计模式/文档设计问题...

This is more of a design pattern / document design question than a technical one...

我想在我的网站上显示一个活动提要,其中会列出用户在我的网站上所做的所有最新事件...以下是我想显示的一些活动:

I want to display a activity feed on my website which will list all the latest happenings users have been doing on my site...here are some of the activities i would like to display:

  • 上传了新媒体(Bob 上传了新曲目)
  • 对个人资料的评论(保罗对鲍勃的个人资料发表了评论)
  • 媒体评论(史蒂夫对保罗的曲目我的曲目名称"发表了评论)
  • 状态更新(史蒂夫可以编写他希望的任何状态更新)

每个活动都需要有自己的数据集,例如新媒体上传的活动,我想包括有关媒体的详细信息,例如图片、标题、描述等).

Each activity will need to have it's own set of data, such as the new media uploaded activity I would like to include details about the media such as image, title, description etc).

此活动将主要用作全局提要,因此对所有用户都是相同的,尽管我需要让用户选择仅显示他们关注的用户(如 Twitter)的提要项目.

This activity will mostly be used as a global feed so it's the same for all users, although I need the option for users to only show feed items from users they are following (like twitter).

我想我有两个选择:

1) 使用索引将所有数据 Ad-Hoc 拉入,以便信息始终是最新的,即使用户更改了他的媒体标题名称...我不确定这将如何扩展??

1) Pull in all the data Ad-Hoc with an index so the information is always up to date, even if a user alters his media title name...i'm not sure how well this will scale though??

2) 有一个 ActivityFeed 文档,其中包含一个子文档,例如 NewMediaUploadActivity(如下所示).

2) Have an ActivityFeed document which contains a Sub-Document such as NewMediaUploadActivity (shown below).

ActivityFeed
 - DateTime
 - AccountId
 - ActivityType
 - Activity (this is a polymorphic object)

NewMediaUploadActivity : Activity
 - MediaTitle
 - MediaDescription
 - GenreName

StatusUpdateActivity : Activity
 - StatusText

ProfileCommentActivity : Activity
 - CommentText
 - ProfileAccountId
 - ProfileUsername

等等...

如果有人有任何经验,或任何关于在 RavenDB 中执行此操作的最佳方法的任何意见,我将不胜感激,我使用 SQL Server 构建的实时网站目前使用稍微修改的选项 2 满足我的需要.

If anybody has any experience, or any input on the best way to do this in RavenDB I would be grateful, my live website built with SQL Server currently does what I need using a slightly modified option 2.

保罗

推荐答案

我会这样建模:

public class ActivityTracking<TActivity>
{
   public string[] AffectedUsers {get;set;}
   public TActivity Activity {get;set;}
}

您可以拥有附加"到不同用户的不同活动(不需要在继承层次结构中).例如,鲍勃对简的照片发表评论会出现在两个信息流中.然后,您只需查询该用户的活动即可.

You can have different activities (not required to be in an inheritance hierarchy) that are "attached" to different users. For example, Bob commenting on Jane's photo would show up in both streams. You then can just query for activities for that user.

这篇关于使用 RavenDb 进行活动流设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆