So recently, I found a pretty helpful way to show data in a tree-like structure.
Say I have a user. The user has a one-to-many relationship with orders
. The orders
have a one-to-many relationship with products
, and a one-to-one relationship to charges. A user document looks like this:
{
"_id": "1234",
"orders": ["1", "2", "3"]
}
So on each part of my view, I iterate over the relations and publish each result. For example:
if Template.subscriptionsReady
with user
+User.profile
h1.title Orders
each orders
+Order.Item _id=this
And my orders template might look like this:
export class Order extends BlazeComponent {
onCreated() {
super.onCreated();
this.autorun(() => this.subscribe('order', this.data()._id));
}
order() {
return Orders.findOne(this.data()._id)
}
}
Order.register('Order.Item');
My question is really, will subscribing to multiple smaller data sources cause a problem?