libgorm

package module
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 5 Imported by: 16

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)
}

DataSource 数据源

type DataSourceAgent added in v0.9.11

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

DataSourceAgent ...

func (*DataSourceAgent) DB added in v0.9.11

func (inst *DataSourceAgent) DB(db *gorm.DB) *gorm.DB

DB 如有需要,获取 DB

func (*DataSourceAgent) Init added in v0.9.11

func (inst *DataSourceAgent) Init(dataSourceManager DataSourceManager, dataSourceName string)

Init 初始化

func (*DataSourceAgent) Ready added in v0.9.11

func (inst *DataSourceAgent) Ready() bool

Ready 确认是否已就绪

type DataSourceManager

type DataSourceManager interface {
	GetDataSource(alias string) (DataSource, error)
	ListAliases() []string
}

DataSourceManager 数据源管理器

type DataSourceRegistration

type DataSourceRegistration struct {
	Alias         string
	Configuration Configuration
	DataSource    DataSource
	Enabled       bool
}

DataSourceRegistration 数据源注册信息

type DataSourceRegistry added in v0.9.11

type DataSourceRegistry interface {
	ListSources() []*DataSourceRegistration
}

DataSourceRegistry 数据源注册器

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 Group added in v0.9.9

type Group interface {
	Prototypes() []any // 列出各种 entity 的原型

}

Group 表示一组相关的表格

type GroupManager added in v0.9.9

type GroupManager interface {
	ListGroups() []*GroupRegistration
}

GroupManager 分组管理器

type GroupRegistration added in v0.9.11

type GroupRegistration struct {
	Enabled bool   // 指出是否启用该 group
	Alias   string // group 的别名 (短名称)
	URI     string // group 的ID名称 (长名称)
	Prefix  string // group 的表名前缀
	Source  string // 数据源的 alias

	Group Group
}

GroupRegistration 分组的注册信息

type GroupRegistry added in v0.9.9

type GroupRegistry interface {

	// 取分组信息
	Groups() []*GroupRegistration
}

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

type TableManager

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

TableManager 是全局的表格管理器

type TableRegistration

type TableRegistration struct {
	SimpleName string
	Group      *Group
	Prototype  any // 原型
}

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

Directories

Path Synopsis
gen
modules
src

Jump to

Keyboard shortcuts

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