xxdbsources

package
v0.0.0-...-63b2ac5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2019 License: GPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSqliteDb

func GetSqliteDb(dbfile string) *gorm.DB

Types

type Datasource

type Datasource interface {
	Name() string
	Dsn() (string, error)
	Connect() *sql.DB
}

func NewSqliteDbs

func NewSqliteDbs(ops ...Option) Datasource

type DbEntity

type DbEntity interface {
	GetType() interface{}
}

type DbGorm

type DbGorm struct {
	IsDebug bool
	// contains filtered or unexported fields
}

func NewDbOrm

func NewDbOrm(opt ...Dboptions) *DbGorm

func (*DbGorm) GetDb

func (this *DbGorm) GetDb() (*gorm.DB, error)

TODO 这些单例获取db 数据源这种操作 可以参考下, 使用sync.Once包实现

func (*DbGorm) GetInitDb

func (this *DbGorm) GetInitDb(tableSchema interface{}) (*gorm.DB, error)

type Dboptions

type Dboptions func(opts *dboptions) error

----------start----------db option impl----------start----------

func WithDataSource

func WithDataSource(dbs Datasource) Dboptions

func WithDebug

func WithDebug() Dboptions

type DsOption

type DsOption func(opt *DsOptions)

func WithCharset

func WithCharset(charset string) DsOption

func WithDbName

func WithDbName(dbname string) DsOption

func WithHost

func WithHost(host string) DsOption

----------start----------option functions----------start----------

func WithPasswd

func WithPasswd(passwd string) DsOption

func WithPort

func WithPort(port int) DsOption

func WithUser

func WithUser(user string) DsOption

type DsOptions

type DsOptions struct {
	Host    string
	Port    int
	Charset string
	DbName  string
	User    string
	Passwd  string
}

type IdModule

type IdModule interface {
	GetId() gormodel.ModelId
	GetModelTime() gormodel.ModelTime
}

type ModelId

type ModelId struct {
	ID uint `gorm:"primary_key"`
}

主键id

type ModelSofeDel

type ModelSofeDel struct {
	DeletedAt *time.Time `sql:"index"`
}

软删除

type ModelTime

type ModelTime struct {
	CreatedAt time.Time
	UpdatedAt time.Time
}

创建和修改时间

type Option

type Option func(_db *Sqlite3Options)

func WithDbFile

func WithDbFile(dbfile string) Option

type Sqlite3Options

type Sqlite3Options struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL