gitee.com/h79/goutils@v1.22.10/dao/db/db.go (about) 1 package db 2 3 import ( 4 "context" 5 "github.com/olivere/elastic/v7" 6 "gorm.io/gorm" 7 ) 8 9 type Sql interface { 10 Db() *gorm.DB 11 Name() string 12 } 13 14 type SqlDatabase interface { 15 Get(name string) (Sql, error) 16 Do(name string, c func(db Sql) error) error 17 Close(name string) 18 CloseAll() 19 Select(name string) 20 GetSelector() string 21 } 22 23 type EsDatabase interface { 24 Get(name string) (*elastic.Client, string, error) 25 Do(name string, call func(es *elastic.Client) error) error 26 Close(name string) error 27 CloseAll() 28 Select(name string) 29 GetSelector() string 30 } 31 32 type ConditionCallback func(ctx context.Context, data interface{}, db *gorm.DB) *gorm.DB