generated from alecodes/base-template
wip: implementing db initialization
This commit is contained in:
parent
ffd3c2014e
commit
d4857c48cf
10 changed files with 383 additions and 0 deletions
53
examples/usage.go
Normal file
53
examples/usage.go
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
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)
|
||||
}
|
||||
Reference in a new issue