diffsync icon indicating copy to clipboard operation
diffsync copied to clipboard

Allow for recursive data models

Open Kircheneer opened this issue 2 years ago • 1 comments

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 https://github.com/networktocode/diffsync/issues/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'] = []

Kircheneer avatar Apr 11 '23 08:04 Kircheneer