generated from alecodes/base-template
feat: add basic readwise example
This commit is contained in:
parent
f58db2ecaa
commit
92c9814e2a
10 changed files with 273 additions and 248 deletions
18
pkg/node.go
18
pkg/node.go
|
|
@ -3,12 +3,14 @@ package synchronizator
|
|||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type StandardNode interface {
|
||||
GetClass() string
|
||||
GetName() string
|
||||
GetMetadata() []byte
|
||||
GetOriginalData() []byte
|
||||
|
||||
AddRelationship(relationship StandardRelationship) error
|
||||
AddRelationships(to int64, relationship []StandardRelationship)
|
||||
|
|
@ -26,14 +28,16 @@ type Node struct {
|
|||
Id int64 // The id of the node
|
||||
name string // The name of the node
|
||||
metadata []byte // Arbitrary data. This is stored as a jsonb in the database
|
||||
originalData []byte // Original response from remote platform
|
||||
}
|
||||
|
||||
func NewNode(name string, metadata []byte) *Node {
|
||||
func NewNode(name string, class string, metadata, originalData []byte) *Node {
|
||||
return &Node{
|
||||
name: name,
|
||||
_class: "NODE",
|
||||
metadata: metadata,
|
||||
Id: -1, // Use -1 to indicate not persisted
|
||||
name: name,
|
||||
_class: strings.ToUpper(class),
|
||||
metadata: metadata,
|
||||
originalData: originalData,
|
||||
Id: -1, // Use -1 to indicate not persisted
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -49,6 +53,10 @@ func (node *Node) GetMetadata() []byte {
|
|||
return node.metadata
|
||||
}
|
||||
|
||||
func (node *Node) GetOriginalData() []byte {
|
||||
return node.originalData
|
||||
}
|
||||
|
||||
func (node *Node) AddRelationship(relationship StandardRelationship) error {
|
||||
node1, node2 := relationship.GetNodes()
|
||||
|
||||
|
|
|
|||
Reference in a new issue