schema

package
v0.1.78 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

元数据注册中心

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Field

type Field struct {
	GoName     string       // 字段名
	ColumnName string       // 列名
	Typ        reflect.Type // 类型
	OffSet     uintptr      // 字段偏移量
}

Field 字段

type Register

type Register struct {
	Schemas sync.Map
}

func NewRegister

func NewRegister() *Register

func (*Register) Get

func (r *Register) Get(val any) (*Schema, error)

func (*Register) Register

func (r *Register) Register(entity any, opts ...SchemaOpt) (*Schema, error)

type Registry

type Registry interface {
	Get(val any) (*Schema, error)
	Register(val any, opts ...SchemaOpt) (*Schema, error)
}

type Schema

type Schema struct {
	TableName string // 表名

	Fields []*Field

	FieldMap map[string]*Field
	// 列名和属性的射映
	ColumnMap map[string]*Field
}

type SchemaOpt

type SchemaOpt func(s *Schema) error

func SchemaWithTableName

func SchemaWithTableName(tableName string) SchemaOpt

func WithColumName added in v0.1.25

func WithColumName(field, colName string) SchemaOpt

type TableName

type TableName interface {
	TableName() string
}

Jump to

Keyboard shortcuts

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