Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nosql RavenDb从ID列表中获取列表_Nosql_Ravendb - Fatal编程技术网

Nosql RavenDb从ID列表中获取列表

Nosql RavenDb从ID列表中获取列表,nosql,ravendb,Nosql,Ravendb,我正在和RavenDb一起开发一个活动经理。登录的用户可以在随后的位置编写帖子,然后在用户墙(主页)中查看所有帖子。每个帖子都可以标记为“喜欢”和“喜欢”。像twitter或facebook这样的小结构 通过我所关注的地方获得帖子的最佳方式是什么?我需要得到喜欢和喜爱的数量,如果我已经在viewmodel上标记了帖子,发送到视图并显示列表。我正在这样尝试,但抛出max requests异常 var myPlaces = this.SessionDb.Query<Ev

我正在和RavenDb一起开发一个活动经理。登录的用户可以在随后的位置编写帖子,然后在用户墙(主页)中查看所有帖子。每个帖子都可以标记为“喜欢”和“喜欢”。像twitter或facebook这样的小结构

通过我所关注的地方获得帖子的最佳方式是什么?我需要得到喜欢和喜爱的数量,如果我已经在viewmodel上标记了帖子,发送到视图并显示列表。我正在这样尝试,但抛出max requests异常

            var myPlaces = this.SessionDb.Query<EventFollow>()
                .Where(ls => ls.UserId == User.Identity.Name)
                .Select(l => l.PlaceId);

            var listPosts = this.SessionDb
                .Advanced.LuceneQuery<Post>().WhereIn("PlaceId", myPlaces)
                .Skip(skip)
                .Take(20)
                .ToList();


            List<PostViewModel> posts = new List<SpottedViewModel>();

            foreach (var p in listPosts)

            {
                PostViewModel vm = new PostViewModel();

                vm.Creator = p.UserCreatorId == User.Identity.Name;

                vm.Like =  this.SessionDb.Query<Lol>().Where(lol => lol.SpottedId == p.Id).Count();

                vm.Favourites = this.SessionDb.Query<Favourite>().Where(fa => fa.SpottedId == p.Id).Count();

                vm.Post= s;

                vm.IsLike = this.SessionDb.Query<Like>().FirstOrDefault(l => l.PostId == p.Id) != null;

                vm.IsFavourite = this.SessionDb.Query<Favourite>().FirstOrDefault(f => f.SpottedId == s.Id) != null;


                posts.Add(vm);
            }

谢谢你,对不起我的英语;D

这里的问题不是从ID列表中获取文档列表,您可以使用IDocumentSession.Load方法并发送文档ID列表,或者像您一样使用where。问题在于你的模型设计

在我看来,您需要对数据模型进行一些认真的重新设计。看起来,它与现在的情况有着很强的关系,而RavenDB并不是关系型的(或者说是针对关系模型进行了优化)。我很难确切地了解您的用例是什么,但从我所看到的情况来看,我可能会在“post”模型中保存“favorites”和“like”,并在“user”模型中保存“EventFollow”


此外,根据RavenDB的原则,每个会话最多只能有30个请求(默认情况下,它是可配置的)。你有一些事情要做,所以到目前为止,你很可能会超过这30个请求。这就是为什么会有例外。

是的,但在RavenDb Group(谷歌)中,一位专家对我说,这种数据模型比先例(比如你的)更好,最终会有很多喜欢或喜欢的东西,这让我感到惊讶。你有那个讨论的链接吗?
            var myPlaces = this.SessionDb.Query<EventFollow>()
                .Where(ls => ls.UserId == User.Identity.Name)
                .Select(l => l.PlaceId);

            var listPosts = this.SessionDb
                .Advanced.LuceneQuery<Post>().WhereIn("PlaceId", myPlaces)
                .Skip(skip)
                .Take(20)
                .ToList();


            List<PostViewModel> posts = new List<SpottedViewModel>();

            foreach (var p in listPosts)

            {
                PostViewModel vm = new PostViewModel();

                vm.Creator = p.UserCreatorId == User.Identity.Name;

                vm.Like =  this.SessionDb.Query<Lol>().Where(lol => lol.SpottedId == p.Id).Count();

                vm.Favourites = this.SessionDb.Query<Favourite>().Where(fa => fa.SpottedId == p.Id).Count();

                vm.Post= s;

                vm.IsLike = this.SessionDb.Query<Like>().FirstOrDefault(l => l.PostId == p.Id) != null;

                vm.IsFavourite = this.SessionDb.Query<Favourite>().FirstOrDefault(f => f.SpottedId == s.Id) != null;


                posts.Add(vm);
            }