Make parent lookup recursive instead of write
This commit is contained in:
10
document.go
10
document.go
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user