fix: sdbc to Driver
This commit is contained in:
parent
108f62aa4d
commit
e63125d1d5
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type _delete struct {
|
||||
scope *scope
|
||||
sdbc *sdbc
|
||||
sdbc *Driver
|
||||
ctx context.Context
|
||||
where []any
|
||||
isHard bool
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
type _find struct {
|
||||
scope *scope
|
||||
sdbc *sdbc
|
||||
sdbc *Driver
|
||||
ctx context.Context
|
||||
where []any
|
||||
selectOpts []interface{}
|
||||
|
@ -4,7 +4,7 @@ import "context"
|
||||
|
||||
type _insert struct {
|
||||
scope *scope
|
||||
sdbc *sdbc
|
||||
sdbc *Driver
|
||||
ctx context.Context
|
||||
selectOpts []interface{}
|
||||
omitOpts []string
|
||||
|
@ -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
|
||||
|
10
scope.go
10
scope.go
@ -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
10
sdbc.go
@ -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")
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type _update struct {
|
||||
scope *scope
|
||||
sdbc *sdbc
|
||||
sdbc *Driver
|
||||
ctx context.Context
|
||||
where []any
|
||||
selectOpts []interface{}
|
||||
|
Loading…
Reference in New Issue
Block a user