Reputation: 962
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
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