Raven DB查询单独文档中的集合

时间:2011-11-13 21:56:34

标签: ravendb

我的方案类似于以下内容:

想象一下,我有三个班级

public class User
{
    public string Id {get;set;}
}

public class FollowableUser
{
    public string Id{get;set;}
    public IEnumerable<string> FollowingUserIds {get;set;}
}

public class Event
{
    public string Id{get;set;}
    public IEnumerable<string> TaggedFollowableUsers {get;set;
}

我想做的是能够通过用户的ID查询并返回所有事件(或至少是事件ID)。

修改的 我尝试过这个,但不确定在减少部分的位置:

 AddMap<Event>(events => from evt in events
                                     from fUser in evt.TaggedFollowableUsers 
                                     select new 
                                                {
                                                    FUserId = fUser,
                                                    EventId = evt.Id,
                                                    UserId = (string)null
                                                });

        AddMap<FollowableUser>(fUsers => from fUser in fUsers
                                  from followingUser in child.FollowedingUserIds
                                  select new
                                             {
                                                 FUserId = fUser.Id,
                                                 EventId = (string) null,
                                                 UserId = followingUser
                                             });
        Reduce = results => from result in results
                            group result by result.FUserId
                            into g
                            select new
                                       {
                                           FUserId= g.Key,
                                           EventId = g.Select(x => x.EventId) // not sure what to do from here
                                       };

这可能与单个可查询索引有关,还是我需要进行多次调用?

谢谢,

马特

0 个答案:

没有答案