wip: implementing db initialization

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

39
pkg/node.go Normal file
View file

@ -0,0 +1,39 @@
package synchronizator
type NodeClass interface {
ToNode() (string, string, []byte, error)
FromNode(string, string, []byte) error
}
type Node struct {
_conn *db
Id int64
_class string
_relationships []*Relationship
name string
metadata []byte
}
func (node *Node) AddRelation(relation RelationshipClass, to int64) (*Relationship, error) {
return node._conn.AddRelation(node.Id, relation, to)
}
func (node *Node) UpdateRelation(metadata any, to int64) error {
return node._conn.UpdateRelation(node.Id, metadata, to)
}
func (node *Node) DeleteRelation(to int64) error {
return node._conn.DeleteRelation(node.Id, to)
}
// func (node *Node) Save() error {
// return node._conn.UpdateNode(node.Id, node.metadata)
// }
func (node *Node) Delete() error {
return node._conn.DeleteNode(node.Id)
}
func (node *Node) Unmarshall(dst NodeClass) error {
return dst.FromNode(node._class, node.name, node.metadata)
}