generated from alecodes/base-template
fix: only bulkAdd new collections instead of all collections
It was duplicating previosly created nodes
This commit is contained in:
parent
4094f71a7d
commit
26b678b348
1 changed files with 13 additions and 9 deletions
|
|
@ -42,24 +42,28 @@ func (platform *Platform) FetchCollections(
|
||||||
|
|
||||||
fmt.Printf("Collections: %v\n", len(platform.Collections))
|
fmt.Printf("Collections: %v\n", len(platform.Collections))
|
||||||
|
|
||||||
err = BulkCreateNode(platform._conn, platform.Collections)
|
err = BulkCreateNode(platform._conn, values)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range platform.Collections {
|
relationships := make([]*Relationship, 0, len(values))
|
||||||
err := platform.AddRelationship(
|
|
||||||
&Relationship{
|
for _, item := range values {
|
||||||
_class: "PLATFORM_HAS_COLLECTION",
|
relation := &Relationship{
|
||||||
From: platform.Id,
|
_class: "PLATFORM_HAS_COLLECTION",
|
||||||
To: item.Id,
|
From: platform.Id,
|
||||||
})
|
To: item.Id,
|
||||||
|
}
|
||||||
|
|
||||||
|
err := platform.AddRelationship(relation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
relationships = append(relationships, relation)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = BulkCreateRelationships(platform._conn, platform._relationships)
|
err = BulkCreateRelationships(platform._conn, relationships)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue