Search code examples
indexingravendbreducemultimap

Multi map reduce index ravendb


I have 2 documents:

Task{ Id:"task/123", name:"abc" }

SubTask{ Id:"subtask/888", TaskId:"task/123" }

I need to fetch tasks and number of subtasks with each task. How can I get this using multimap reduce index.


Solution

  • You can use a simple map/reduce index to count the number of the subtasks per task, then include the task from the index, so you get the count of subtasks and the task itself in one roundtrip