How to load one-to-many relationships in the Data Mapper?

While I will use the Ghost template in a 1: 1 ratio, I'm not sure if this is enough in a 1: n ratio.

For example, when I load an Order object that can have 100 Item objects, I would first set NULL to the items property.

The question arises:

A) Should I assign NULL, and then, the first time I access the property of the elements, find ALL orders of this element and load ALL of them?

B) Or should I load only a lightweight record set containing only all order_id and load 100 Ghost objects that have only the order_id set, but everything else is NULL - and as soon as the Item object is available to receive more detailed information from it, lazy-load What is the specific data of the object of the object?

+5
source share
1 answer

Well, IMO, your lazy loading needs vary in every situation. However, I would say that if you have orders large enough to have 100 items on them, there is rarely a time when you want to load all 100 items at once.

, , . , , ", , . , , , , 10 Ghost, 10 .

, , , , .

+1

All Articles