Documentation
¶
Index ¶
- func GetDsn(c Config) string
- func NewDB(dsn string) (*gorm.DB, error)
- func NewDefaultDB() (*gorm.DB, error)
- type Association
- type BaseMapper
- func (m *BaseMapper[T]) Delete(entity T) error
- func (m *BaseMapper[T]) Detail(entity T) (res T, err error)
- func (m *BaseMapper[T]) First(entity T) (res T, err error)
- func (m *BaseMapper[T]) Insert(entity *T) error
- func (m *BaseMapper[T]) List(entity *T) (res []T, err error)
- func (m *BaseMapper[T]) ListWithPage(entity *T, page, pageSize int) (res []T, err error)
- func (m *BaseMapper[T]) Update(entity *T, omits ...interface{}) error
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Association ¶ added in v1.0.10
type Association struct { Query string Args interface{} }
Association 关联模型结构体
type BaseMapper ¶
type BaseMapper[T any] struct { Associations []Association // 关联 }
func (*BaseMapper[T]) Detail ¶
func (m *BaseMapper[T]) Detail(entity T) (res T, err error)
Detail 详情
func (*BaseMapper[T]) First ¶ added in v1.0.10
func (m *BaseMapper[T]) First(entity T) (res T, err error)
First 单条记录
func (*BaseMapper[T]) ListWithPage ¶ added in v1.0.10
func (m *BaseMapper[T]) ListWithPage(entity *T, page, pageSize int) (res []T, err error)
ListWithPage 列表带分页
func (*BaseMapper[T]) Update ¶
func (m *BaseMapper[T]) Update(entity *T, omits ...interface{}) error
Update 更新
type Config ¶
type Config struct { User string `json:"user" xml:"user" yaml:"user" form:"user"` Password string `json:"password" xml:"password" yaml:"password" form:"password"` Host string `json:"host" xml:"host" yaml:"host" form:"host"` Port string `json:"port" xml:"port" yaml:"port" form:"port"` Database string `json:"database" xml:"database" yaml:"database" form:"database"` Charset string `json:"charset" xml:"charset" yaml:"charset" form:"charset"` }
Config 连接数据库
Click to show internal directories.
Click to hide internal directories.