user2981411
user2981411

Reputation: 962

RavenDB Hierarchial Data Manipulation

We have a Blog engine stored in RavenDB. The Blog Posts are separate documents to the Comments. What we need to do is to create an Index that retrieves our blog posts as normal but also includes a field for the sum of the comments (i.e. the count as a number) belonging to each Blog Post. Of course each comment document has the Blog Post Id as a foreign key.

Many thanks

Upvotes: 0

Views: 31

Answers (1)

Ayende Rahien
Ayende Rahien

Reputation: 22956

The easiest way to handle that is to do a map/reduce index that would count the number of comments per blog post. Then you query the index for the count as part of loading the blog post (you can do that using Lazy).

Upvotes: 1

Related Questions