Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How-to create index on multiple documents with reducing

Tags:

c#

ravendb

I've the following documents :

    public class User
    {
        public string Id { get; set; }
        public string Email { get; set; }
        public string Password { get; set; }
    }

    public class Book
    {
        public string Id { get; set; }
        public string Title { get; set; }
    }

    public class BookFavorite
    {
        public string Id { get; set; }
        public string UserId { get; set; }
        public string BookId { get; set; }
    }

I want to query the list of books and have an information on each book if user has it in favorite.

Actually a result like this :

    public class QueryResult
    {
        public Book Book { get; set; }
        public User User { get; set; }
        public bool IsInFavorite { get; set; }
    }

How can i create my index to perform that ?

Thanks.

like image 328
Yoann. B Avatar asked Feb 11 '26 03:02

Yoann. B


1 Answers

Please look at this: http://ayende.com/blog/89089/ravendb-multi-maps-reduce-indexes

It shows how you can join the documents to show the favorite for the users.

like image 165
Ayende Rahien Avatar answered Feb 13 '26 18:02

Ayende Rahien