gormx

package
v0.0.0-...-6797358 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DDL

type DDL struct {
	DefaultOnDelete FKAction
	DefaultOnUpdate FKAction
	// contains filtered or unexported fields
}

func NewDDL

func NewDDL(db *gorm.DB) *DDL

func (*DDL) AddFK

func (s *DDL) AddFK(table, target interface{}, fk string)

func (*DDL) AddFKs

func (s *DDL) AddFKs(table interface{})

func (*DDL) AddForeignKey

func (s *DDL) AddForeignKey(table, fkey, target, targetCol string, onDelete, onUpdate FKAction)

func (*DDL) AddTables

func (s *DDL) AddTables(tables ...interface{})

func (*DDL) GetSchema

func (s *DDL) GetSchema(obj interface{}) *schema.Schema

func (*DDL) GetSchemaByStructName

func (s *DDL) GetSchemaByStructName(structName string) *schema.Schema

func (*DDL) MakeFKName

func (s *DDL) MakeFKName(table, fkey, target, targetCol string) string

func (*DDL) MakeFKs

func (s *DDL) MakeFKs()

func (*DDL) MatchTableName

func (s *DDL) MatchTableName(structType reflect.Type, tableName string) bool

func (*DDL) ParseFKInfo

func (s *DDL) ParseFKInfo(tag string) FKInfo

tag: eg. FK:User,CASCADE,CASCADE Table,on delete %s,on update %s

func (*DDL) Range

func (s *DDL) Range(f func(structType reflect.Type, tableSchema *schema.Schema) bool)

type FKAction

type FKAction string
const (
	FKEmpty    FKAction = ""
	FKCascade  FKAction = "CASCADE"
	FKNoAction FKAction = "NO ACTION"
	FKSetNull  FKAction = "SET NULL"
	FKRestrict FKAction = "RESTRICT"
)

type FKInfo

type FKInfo struct {
	StructName string
	OnDelete   FKAction
	OnUpdate   FKAction
}

Jump to

Keyboard shortcuts

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