generated from alecodes/base-template
36 lines
777 B
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)
|
|
// }
|