wp-go/model/model.go

32 lines
600 B
Go
Raw Normal View History

2023-01-12 12:42:16 +00:00
package model
import (
"context"
)
var _ ParseWhere = SqlBuilder{}
var globalBb dbQuery[Model]
2023-01-12 12:42:16 +00:00
func InitDB(db dbQuery[Model]) {
2023-01-12 12:42:16 +00:00
globalBb = db
}
type QuerySelect[T any] func(context.Context, string, ...any) ([]T, error)
type QueryGet[T any] func(context.Context, string, ...any) (T, error)
2023-02-10 13:23:30 +00:00
2023-01-12 12:42:16 +00:00
type Model interface {
PrimaryKey() string
Table() string
}
type ParseWhere interface {
ParseWhere(*[][]any) (string, []any, error)
}
type dbQuery[T any] interface {
Select(context.Context, string, ...any) ([]T, error)
Get(context.Context, string, ...any) (T, error)
2023-01-12 12:42:16 +00:00
}
type SqlBuilder [][]string