generated from alecodes/base-template
39 lines
967 B
Go
39 lines
967 B
Go
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)
|
|
}
|