fix: sdbc to Driver

This commit is contained in:
xuthus5 2023-09-16 20:21:42 +08:00
parent 108f62aa4d
commit e63125d1d5
Signed by: xuthus5
GPG Key ID: A23CF9620CBB55F9
7 changed files with 15 additions and 15 deletions

View File

@ -7,7 +7,7 @@ import (
type _delete struct {
scope *scope
sdbc *sdbc
sdbc *Driver
ctx context.Context
where []any
isHard bool

View File

@ -8,7 +8,7 @@ import (
type _find struct {
scope *scope
sdbc *sdbc
sdbc *Driver
ctx context.Context
where []any
selectOpts []interface{}

View File

@ -4,7 +4,7 @@ import "context"
type _insert struct {
scope *scope
sdbc *sdbc
sdbc *Driver
ctx context.Context
selectOpts []interface{}
omitOpts []string

View File

@ -141,7 +141,7 @@ func file_model_proto_rawDescGZIP() []byte {
var file_model_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_model_proto_goTypes = []interface{}{
(*ModelArticles)(nil), // 0: sdbc.ModelArticles
(*ModelArticles)(nil), // 0: Driver.ModelArticles
}
var file_model_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type

View File

@ -21,34 +21,34 @@ func (m *model) ptr() any {
type scope struct {
*model
*sdbc
*Driver
}
func (s *scope) Insert() *_insert {
return &_insert{
scope: s,
sdbc: s.sdbc,
sdbc: s.Driver,
}
}
func (s *scope) Find() *_find {
return &_find{
scope: s,
sdbc: s.sdbc,
sdbc: s.Driver,
}
}
func (s *scope) Update() *_update {
return &_update{
scope: s,
sdbc: s.sdbc,
sdbc: s.Driver,
}
}
func (s *scope) Delete() *_delete {
return &_delete{
scope: s,
sdbc: s.sdbc,
sdbc: s.Driver,
}
}

10
sdbc.go
View File

@ -29,17 +29,17 @@ type Config struct {
Debug bool // 是否开启debug
}
type sdbc struct {
type Driver struct {
dbname string
client *gorm.DB
}
func NewSDBC(cfg *Config) *sdbc {
func NewSDBC(cfg *Config) *Driver {
if cfg == nil {
logrus.Fatalf("config can not be nil")
}
var (
driver = new(sdbc)
driver = new(Driver)
err error
)
driver.client, err = gorm.Open(sqlite.Open(cfg.Dbname), &gorm.Config{})
@ -66,11 +66,11 @@ func NewSDBC(cfg *Config) *sdbc {
return driver
}
func (s *sdbc) GetClient() *gorm.DB {
func (s *Driver) GetClient() *gorm.DB {
return s.client
}
func (s *sdbc) BindModel(prototype any) Operator {
func (s *Driver) BindModel(prototype any) Operator {
if prototype == nil {
logrus.Panic("model can not be nil")
}

View File

@ -7,7 +7,7 @@ import (
type _update struct {
scope *scope
sdbc *sdbc
sdbc *Driver
ctx context.Context
where []any
selectOpts []interface{}