generated from alecodes/base-template
feat: allow to fetch nodes
This commit is contained in:
parent
3cf643c83d
commit
8af94161ab
8 changed files with 141 additions and 30 deletions
|
|
@ -23,7 +23,7 @@ type PlatformClass interface {
|
|||
// the node's functionality is available.
|
||||
type Platform struct {
|
||||
Node // Underlaying node info
|
||||
collections []*Collection // Child nodes
|
||||
Collections []*Collection // Child nodes
|
||||
}
|
||||
|
||||
type Fetcher = func(pagination Pagination) ([]*Collection, Pagination, error)
|
||||
|
|
@ -47,13 +47,13 @@ func (platform *Platform) FetchCollections(fetcher Fetcher, start_pagination Pag
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
platform.collections = slices.Concat(platform.collections, collections)
|
||||
platform.Collections = slices.Concat(platform.Collections, collections)
|
||||
|
||||
if pagination.HasMore {
|
||||
return platform.FetchCollections(fetcher, pagination)
|
||||
}
|
||||
|
||||
err = BulkCreateNode(platform._conn, platform.collections)
|
||||
err = BulkCreateNode(platform._conn, platform.Collections)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue