f3-cortex icon indicating copy to clipboard operation
f3-cortex copied to clipboard

1:m self relation

Open olaulau opened this issue 2 years ago • 1 comments

hi ;

is it possible, and what would be the fieldConf of a 1:m self referring relationship ? example : employee table has a manager field, which is a foreign key to employee->id this describes a tree, which we should traverse in both direction (up and down).

thanks.

olaulau avatar Oct 16 '23 16:10 olaulau

Yes it's possible. Simply point it to the model itself. Manager is a belongs to one field config and another field, i.e. "manages" can be added to fieldConf that is a has-many configuration, pointing to the manager-id field, which will contain all the child employees the manager will manage.

ikkez avatar Oct 17 '23 22:10 ikkez