From e63125d1d5e432dd35c670608f826d94df3e480d Mon Sep 17 00:00:00 2001 From: xuthus5 Date: Sat, 16 Sep 2023 20:21:42 +0800 Subject: [PATCH] fix: sdbc to Driver --- delete_scope.go | 2 +- find_scope.go | 2 +- insert_scope.go | 2 +- model.pb.go | 2 +- scope.go | 10 +++++----- sdbc.go | 10 +++++----- update_scope.go | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/delete_scope.go b/delete_scope.go index 07d32ef..caf315a 100644 --- a/delete_scope.go +++ b/delete_scope.go @@ -7,7 +7,7 @@ import ( type _delete struct { scope *scope - sdbc *sdbc + sdbc *Driver ctx context.Context where []any isHard bool diff --git a/find_scope.go b/find_scope.go index 1297e62..552f68e 100644 --- a/find_scope.go +++ b/find_scope.go @@ -8,7 +8,7 @@ import ( type _find struct { scope *scope - sdbc *sdbc + sdbc *Driver ctx context.Context where []any selectOpts []interface{} diff --git a/insert_scope.go b/insert_scope.go index 8e073c1..dad600f 100644 --- a/insert_scope.go +++ b/insert_scope.go @@ -4,7 +4,7 @@ import "context" type _insert struct { scope *scope - sdbc *sdbc + sdbc *Driver ctx context.Context selectOpts []interface{} omitOpts []string diff --git a/model.pb.go b/model.pb.go index b37a270..3072496 100644 --- a/model.pb.go +++ b/model.pb.go @@ -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 diff --git a/scope.go b/scope.go index 5914a76..444b0fa 100644 --- a/scope.go +++ b/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, } } diff --git a/sdbc.go b/sdbc.go index da677e9..ca4b03d 100644 --- a/sdbc.go +++ b/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") } diff --git a/update_scope.go b/update_scope.go index ed65db8..b6a4695 100644 --- a/update_scope.go +++ b/update_scope.go @@ -7,7 +7,7 @@ import ( type _update struct { scope *scope - sdbc *sdbc + sdbc *Driver ctx context.Context where []any selectOpts []interface{}