generated from alecodes/base-template
feat: add collection-node relationship in collection.FetchNodes()
This commit is contained in:
parent
c1684c8dea
commit
d1a0212cb1
2 changed files with 29 additions and 1 deletions
|
|
@ -100,6 +100,26 @@ func (collection *Collection) FetchNodes(fetcher NodeFetcher, start_pagination P
|
|||
}
|
||||
|
||||
err = BulkCreateNode(collection._conn, collection.childs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, item := range collection.childs {
|
||||
err := collection.AddRelationship(
|
||||
&Relationship{
|
||||
_class: "COLLECTION_HAS_NODE",
|
||||
From: collection.Id,
|
||||
To: item.Id,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err = BulkCreateRelationships(collection._conn, collection._relationships)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue