libgorm

package module
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 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)
	ListNames() []string
}

DataSourceManager 数据源管理器

type DataSourceRegistration

type DataSourceRegistration struct {
	Enabled    bool
	Name       string
	DataSource DataSource
	Groups     []string
}

DataSourceRegistration 数据源注册信息

type Database

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

Database 数据库实例

type DatabaseAgent added in v0.9.9

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

DatabaseAgent ...

func (*DatabaseAgent) DB added in v0.9.9

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

DB 如有需要,获取 DB

func (*DatabaseAgent) Init added in v0.9.9

func (inst *DatabaseAgent) Init(db Database)

Init 初始化

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 struct {
	Enabled    bool                    // 指出是否启用该 group
	Name       string                  // group 的名称
	Prefix     string                  // group 的表名前缀
	OnInit     func(ctx *TableContext) // OnInit 函数用于初始化这个表格组
	Prototypes []any                   // 列出各种 entity 的原型
}

Group 表示一组相关的表格

type GroupManager added in v0.9.9

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

GroupManager 分组管理器

type GroupRegistry added in v0.9.9

type GroupRegistry interface {

	// 取分组信息
	Group() *Group
}

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

type TableContext added in v0.9.9

type TableContext struct {
	Database Database
}

TableContext 是表格组的初始化参数

type TableManager

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

TableManager 是全局的表格管理器

type TableRegistration

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

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

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