generated from alecodes/base-template
wip: implementing db initialization
This commit is contained in:
parent
ffd3c2014e
commit
89d7b8130a
18 changed files with 745 additions and 0 deletions
39
pkg/node.go
Normal file
39
pkg/node.go
Normal 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)
|
||||
}
|
||||
Reference in a new issue