hicommonwealth / commonwealth

A platform for decentralized communities
https://commonwealth.im
GNU General Public License v3.0
68 stars 44 forks source link

SuperSeed #7723

Open timolegros opened 6 months ago

timolegros commented 6 months ago

Description

The seed utility currently only seeds from the top-down. That is, if you seed a community, all relevant/required children will be seeded as well. We need to implement bottoms-up seeding so that when you seed a leaf record (e.g. CommentSubscriptions), all parent records are automatically seeded unless explicitly defined.

For example, I should be able to call superSeed('CommentSubscriptions'); and it will see first a community, then a topic, then a thread, then a comment, and then finally the comment subscription. All these seeds should be returned so that properties can be accessed.

Rotorsoft commented 3 months ago

This can be tricky given that data models could have other functional constraints that are not necessary found in the associations tree... but we can handle this inside the test if necessary.

For example, when seeding a Comment, we will find "BelongsTo" associations to Thread, Community, and Address, but there is nothing telling us that when seeding those 3 new records, the Address should "also" be associated to the same Community if there is a functional rule that says "only community members can add comments".

Consider following the "BelongsTo" associations tree (bottom-up) when implementing this feature.