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))
|
||||
|
||||
err = BulkCreateNode(platform._conn, platform.Collections)
|
||||
err = BulkCreateNode(platform._conn, values)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, item := range platform.Collections {
|
||||
err := platform.AddRelationship(
|
||||
&Relationship{
|
||||
_class: "PLATFORM_HAS_COLLECTION",
|
||||
From: platform.Id,
|
||||
To: item.Id,
|
||||
})
|
||||
relationships := make([]*Relationship, 0, len(values))
|
||||
|
||||
for _, item := range values {
|
||||
relation := &Relationship{
|
||||
_class: "PLATFORM_HAS_COLLECTION",
|
||||
From: platform.Id,
|
||||
To: item.Id,
|
||||
}
|
||||
|
||||
err := platform.AddRelationship(relation)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
relationships = append(relationships, relation)
|
||||
}
|
||||
|
||||
err = BulkCreateRelationships(platform._conn, platform._relationships)
|
||||
err = BulkCreateRelationships(platform._conn, relationships)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue