Make parent lookup recursive instead of write

This commit is contained in:
Ian Gulliver
2023-10-16 15:28:58 -07:00
parent 72950ba0ba
commit a7a8fd5272
2 changed files with 16 additions and 4 deletions

View File

@@ -22,6 +22,16 @@ func NewDocumentWithData(data any) *Document {
return doc
}
func (d *Document) AllParents() []*Document {
ret := append([]*Document{}, d.Parents...)
for _, parent := range d.Parents {
ret = append(ret, parent.AllParents()...)
}
return ret
}
func (d *Document) String() string {
return d.ID.String()
}