문제

I have an object like "Library":

public class Library
{
    List Books {get; set}
}

Book
{
    string isbn
}

I want to make an index so from a given isbn I can find the library I can't figure out how to make the map reduce.

도움이 되었습니까?

해결책

No reduce would be necessary to index by isbn. Think of reduce when you need aggregates (sum, count, average, min, max, etc.)

In fact, you don't even need to write the index yourself. Just let Raven do the work for you with it's dynamic index features.

var librariesContainingTheBook = session.Query<Library>()
                                 .Where(x=> x.Books.Any(y=> y.isbn == yourIsbn))

RavenDB should be able to parse this query and build the index automatically.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top