mirror of
https://github.com/wisplite/tether.git
synced 2026-05-01 06:22:41 -05:00
added example program for testing
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package tether
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
|
||||
"github.com/wisplite/tether/reactivity"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -13,15 +15,16 @@ type Engine struct {
|
||||
}
|
||||
|
||||
func NewEngine(db *gorm.DB) *Engine {
|
||||
slog.SetLogLoggerLevel(slog.LevelDebug)
|
||||
return &Engine{db: db, channels: make(map[string]*reactivity.Channel), mutations: make(map[string]func(ctx *MutationCtx) error), queries: make(map[string]func(ctx *QueryCtx) error)}
|
||||
}
|
||||
|
||||
func (e *Engine) RegisterMutation(name string, mutation func(ctx *MutationCtx) error) {
|
||||
e.mutations[name] = mutation
|
||||
slog.Debug("Registered mutation", "name", name)
|
||||
}
|
||||
|
||||
func (e *Engine) RegisterQuery(name string, query func(ctx *QueryCtx) error) {
|
||||
e.queries[name] = query
|
||||
slog.Debug("Registered query", "name", name)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user