This repository has been archived on 2025-05-15. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
synchronizator-go/examples/usage.go

53 lines
951 B
Go

package main
import (
"database/sql"
"fmt"
synchronizator "git.alecodes.page/alecodes/synchronizator/pkg"
_ "modernc.org/sqlite"
)
type ProgrammingLanguage struct {
Name string
}
type Library struct {
Version string `json:"version"`
}
type BelognsTo struct{}
func main() {
connection, err := sql.Open("sqlite", "db.sql")
if err != nil {
fmt.Println(err)
return
}
defer connection.Close()
opts := synchronizator.DefaultOptions
opts.Log_level = synchronizator.DEBUG
opts.DANGEROUSLY_DROP_TABLES = true
sync, err := synchronizator.New(connection, opts)
if err != nil {
fmt.Println(err)
return
}
sync.RegisterNodeClass(Library{})
// collection, err := sync.NewCollection(ProgrammingLanguage{Name: "foo"})
node, err := sync.NewNode("React", Library{Version: "v22"})
// node, err := sync.GetNode(1)
if err != nil {
fmt.Println(err)
return
}
// fmt.Printf("\n%+v\n", collection)
fmt.Printf("\n%+v\n", node)
}