wip: implementing db initialization

This commit is contained in:
Alexander Navarro 2024-11-13 19:55:02 +00:00
parent ffd3c2014e
commit ba3e7b3d38
18 changed files with 803 additions and 0 deletions

36
pkg/collection.go Normal file
View file

@ -0,0 +1,36 @@
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)
// }