Allow for recursive data models
Kircheneer opened this issue · 1 comments
Kircheneer commented
Environment
- DiffSync version: latest
Proposed Functionality
Allow for models to have a model of their own type as children.
Use Case
When modelling locations for example, a location of type country might have locations of type city as its children. Example (assuming #222 is implemented):
class Location(DiffSyncModel):
_modelname = "location"
_identifiers = ("name", "location_type", "$parent")
_children = {"location": "location_children"}
name: str
location_type: str
location_children: List['Location'] = []
jamesharr commented
Duplicate #238 has some more example model code that might be useful for initial testing.
The short version is that it looks like it's not far away from working. Where it's broken right now is that children items are processed multiple times.
I don't know the internals well enough to know if this is a change to an iteration method to avoid double processing items, or if it's more of a structural change where the API will need to change to support multiple backends