libgorm

package module
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 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 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
	PrefixSetter func(prefix string) // 用于设置本分组的表格名称前缀
}

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 TableNameGetter added in v0.9.1

type TableNameGetter interface {
	TableName() string
}

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

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
test command

Jump to

Keyboard shortcuts

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