使用 RavenDb 进行活动流设计

发布于 2024-12-29 14:00:21 字数 1015 浏览 1 评论 0原文

这更多的是一个设计模式/文档设计问题,而不是一个技术问题...

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

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

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

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

我想我有 2 个选择:

1)使用索引提取所有数据,以便信息始终是最新的,即使用户更改了他的媒体标题名称......我不确定这会效果如何规模虽然??

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

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 来满足我的需要

。Paul

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:

  • New media uploaded (Bob has uploaded a new track)
  • Comments on a profile (Paul has commented on Bob's profile)
  • Comments on media (Steve has commented on Paul's track 'my track name')
  • Status updates (Steve can write any status update he wishes)

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).

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).

I think I have 2 options:

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) 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

Etc...

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.

Paul

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人间不值得 2025-01-05 14:00:21

我将其建模为:

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

您可以拥有“附加”到不同用户的不同活动(不需要位于继承层次结构中)。
例如,鲍勃对简照片的评论将出现在两个流中。
然后,您可以查询该用户的活动。

I would model this as:

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文