Query 1:n relationships in RavenDb

Viewed 32

i'm having problems indexing my data in RavenDB in a way I can query it as deserved:

I have a list of Documents of type Product:

public class Product
    {
        public string Id => Asin;
        public string Url { get; set; }
        public string Name { get; set; }
        public string Asin => Url.Split("/").LastOrDefault();
        public string Description { get; set; }
        public List<Category> Categories { get; set; } = new List<Category>();
    }

and a list of type Snapshot:

public class Snapshot
{
    public string Asin { get; set; }
    public DateTime Timestamp { get; set; }
    public string Price { get; set; }
    public int? Ratings { get; set; }
}

I should be able to create a 1:n relation between Product and Snapshot, meaning:

One Product with a unique field Asin can have many Snapshots with that Asin that can be identified by a unique field Timestamp like:

public class ProductWithSnapshots
{
    public Product P { get; set; }
    public List<Snapshot> S { get; set; }
}

=> which I could query the way I need...

I am absolutely new to RavenDb and would be delighted if there was anyone out there who could help. I digged into the documentation (Indexing / Map-Reduce, Querying, etc.) and many posts, but I simply cannot find a better way to address my problem.

Many thanks, guys!

Max

0 Answers
Related