def

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveIndexNameAndUsing

func ResolveIndexNameAndUsing(s string) (name string, using string)

Types

type ColumnDef

type ColumnDef struct {
	Type       typx.Type
	Tag        reflect.StructTag
	DataType   string
	Width      uint64
	Precision  uint64
	Default    *string
	OnUpdate   *string
	Null       bool
	AutoInc    bool
	Comment    string
	Desc       []string
	Relation   []string
	Deprecated *DeprecatedActions
}

ColumnDef describes source and database model

func ParseColDef

func ParseColDef(t typx.Type, tag reflect.StructTag) *ColumnDef

func (*ColumnDef) ParseDBTag

func (d *ColumnDef) ParseDBTag(flag *reflectx.Flag)

type DeprecatedActions

type DeprecatedActions struct {
	RenameTo string `name:"rename"`
}

type KeyColumnOption

type KeyColumnOption struct {
	Name    string // maybe column name or field name
	Options []string
}

func KeyColumnOptionByNames

func KeyColumnOptionByNames(names ...string) []KeyColumnOption

func ResolveKeyColumnOptions

func ResolveKeyColumnOptions(s string) (options []KeyColumnOption)

func ResolveKeyColumnOptionsFromStrings

func ResolveKeyColumnOptionsFromStrings(ss ...string) (options []KeyColumnOption)

func (*KeyColumnOption) String

func (o *KeyColumnOption) String() string

type KeyDefine

type KeyDefine struct {
	Kind    KeyKind
	Name    string
	Using   string
	Comment string
	Options []KeyColumnOption
}

func ParseKeyDef

func ParseKeyDef(def string) *KeyDefine

ParseKeyDef parses key define eg:

| Kind         | Name[,Using]       | Field[,Option]                |
| :---         | :---               | :----                         |
| idx          | idx_name,BTREE     | Name                          |
| index        | idx_name,GIST      | Geo,gist_trgm_ops             |
| unique_index | idx_name           | f_org_id,NULLS,FIRST;MemberID |
| u_idx        | idx_name           | OrgID;f_member_id,NULLS,FIRST |
| primary      |                    | ID                            |
| pk           |                    | ID                            |

func (*KeyDefine) OptionsNames

func (d *KeyDefine) OptionsNames() []string

func (*KeyDefine) OptionsStrings

func (d *KeyDefine) OptionsStrings() []string

type KeyKind

type KeyKind int8
const (
	KEY_KIND__INDEX KeyKind = iota + 1
	KEY_KIND__UNIQUE_INDEX
	KEY_KIND__PRIMARY
)

Jump to

Keyboard shortcuts

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