This repository has been archived on 2025-05-15. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
synchronizator-go/pkg/collection.go

36 lines
777 B
Go

package synchronizator
import "fmt"
type Collection struct {
Node
childs []*Node
}
type collection_relation struct{}
func (collection *collection_relation) ToRelationship() (string, []byte, error) {
return "COLLECTION_HAS", nil, nil
}
func (collection *collection_relation) FromRelationship(_class string, metadata []byte) error {
if _class != "COLLECTION_HAS" {
return fmt.Errorf("invalid class %s", _class)
}
return nil
}
func (collection *Collection) AddChild(node *Node) error {
_, err := collection.AddRelation(&collection_relation{}, node.Id)
if err != nil {
return err
}
collection.childs = append(collection.childs, node)
return nil
}
// func (node *Collection) Save() error {
// return node._conn.UpdateCollection(node.Id, node.metadata)
// }