0
votes

I'm just getting started with RavenDB and have studied the documentation about related documents. The system that I am thinking about working on has two classes, Family and Member.

A Family can have many Members and a Member can belong to many Families. Members can be retrieved individually as well and updated. From what I'm reading, the proper way to model this is to have a Document for Family and another document for Member. And to have Family contain a list of MemberIds.

Great!

The above approach is described on the RavenDB site at https://ravendb.net/docs/article-page/3.0/csharp/indexes/querying/handling-document-relationships

But, this means that you handle each of the object separately. You have to "fetch" each of the Member object individually by using a separate Load command. Even if you use an Include to "prefetch" all of the related objects into the session, you still have to issue a separate Load command for each one.

This means that the Family object doesn't contain a list of Member objects but only contains a list of MemberIds.

Here is my question: Is there a way to have RavenDB return a complex object from related documents so that when you get back a Family object, it will contain a list of the members objects that are related? I know that if you put the member objects directly in the family object, this can be done, but that will not allow a member object to be used elsewhere (other families).

Furthermore, is there a way to tell RavenDB to "deconstruct" certain embedded lists into related documents instead of storing it in the same document?

It seems like this would be a very helpful thing to have.

1

1 Answers

0
votes

You can use a transformer for that, yes.