libgorm

package module
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 5 Imported by: 34

README

libgorm

Starter for using database with Gorm

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ModuleBuilder

func ModuleBuilder() *application.ModuleBuilder

ModuleBuilder 用于创建模块 ['github.com/starter-go/libgorm']

Types

type Agent added in v0.9.7

type Agent interface {
	DB(db *gorm.DB) *gorm.DB
}

Agent 是默认的数据源代理

type Configuration

type Configuration struct {
	Driver   string
	User     string
	Password string
	Host     string
	Port     int
	Database string
	Enabled  bool
}

Configuration 数据源配置信息

type DataSource

type DataSource interface {
	DB() (*gorm.DB, error)
	Registration() *DataSourceRegistration
}

DataSource 数据源

type DataSourceManager

type DataSourceManager interface {
	GetDataSource(name string) (DataSource, error)
}

DataSourceManager 数据源管理器

type DataSourceRegistration

type DataSourceRegistration struct {
	Name       string
	DataSource DataSource
}

DataSourceRegistration 数据源注册信息

type Database

type Database interface {
	DB() *gorm.DB
}

Database 数据库实例

type DatabaseBuilder

type DatabaseBuilder struct {
	DB *gorm.DB
}

DatabaseBuilder 用来创建 Database 实例

func (*DatabaseBuilder) Create

func (inst *DatabaseBuilder) Create() Database

Create 创建 Database 实例

type Driver

type Driver interface {
	Open(c *Configuration) (Database, error)
	Registration() *DriverRegistration
}

Driver 驱动

type DriverManager

type DriverManager interface {
	FindDriver(name string) (Driver, error)
}

DriverManager 驱动管理器

type DriverRegistration

type DriverRegistration struct {
	Name   string
	Driver Driver
}

DriverRegistration 驱动注册信息

type EmptyTable

type EmptyTable struct {
	ID int
}

EmptyTable 是一个用于占位的空表

type TableGroup

type TableGroup struct {
	Name        string
	Namespace   string
	NamerSetter func(namer TableNamer) // 用于设置本分组的表格命名者
}

TableGroup 表示一组相关的表格

type TableGroupBuilder

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

TableGroupBuilder 用于创建一组相关的表格信息

func (*TableGroupBuilder) Create

func (inst *TableGroupBuilder) Create() []*TableRegistration

Create 创建表格组

func (*TableGroupBuilder) Entity added in v0.9.1

func (inst *TableGroupBuilder) Entity(ent any) *TableGroupBuilder

Entity 以 Entity 的形式添加一个表格

func (*TableGroupBuilder) Group

Group 设置分组信息

func (*TableGroupBuilder) Table

Table 添加一个表格

type TableManager

type TableManager interface {
	ListAll() []*TableRegistration
}

TableManager 是全局的表格管理器

type TableNameCache added in v0.9.3

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

TableNameCache ...

func (*TableNameCache) Init added in v0.9.3

func (inst *TableNameCache) Init(namer TableNamer, ns string, simpleName string)

Init ...

func (*TableNameCache) Name added in v0.9.3

func (inst *TableNameCache) Name() string

Name 取表名

type TableNameGetter added in v0.9.1

type TableNameGetter interface {
	TableName() string
}

TableNameGetter 用于从实体原型获取表名

type TableNamer added in v0.9.3

type TableNamer interface {
	GetName(namespace, simpleName string) string
}

TableNamer 是一个名称映射器,它根据传入的 namespace & simpleName 返回全名

type TableNamerRegistration added in v0.9.3

type TableNamerRegistration struct {
	Priority int // 是这个 TableNamer 的优先级,数值越大越先处理
	Namer    TableNamer
}

TableNamerRegistration 是 TableNamer 的注册信息

type TableNamerRegistry added in v0.9.3

type TableNamerRegistry interface {
	Registration() *TableNamerRegistration
}

TableNamerRegistry 表示一个 TableNamer 的注册器

type TableRegistration

type TableRegistration struct {
	SimpleName      string
	Group           *TableGroup
	PrototypeGetter func() any    // 用于获取原型
	NameGetter      func() string // 用于获取完整名称
}

TableRegistration 表示一个表格的注册信息

type TableRegistry

type TableRegistry interface {
	ListTableRegistrations() []*TableRegistration
}

TableRegistry 是一个自动化的表格注册器

Directories

Path Synopsis
gen
src
configen command
demo command
test command

Jump to

Keyboard shortcuts

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