Documentation ¶
Index ¶
Constants ¶
const ( TAG_BASE = "orm" TAG_PK = "pk" TAG_AUTO = "auto" TAG_TYPE = "type" TAG_SIZE = "size" TAG_VALID = "valid" TAG_COLUMN = "column" TAG_DEFAULT = "default" TAG_COMMENT = "comment" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct { Name string // expresses the name of a column Type string // expresses the datatype of a column Tags *Tag // expresses the tags of a colum in Go }
Field represents a column of database
type Schema ¶
type Schema struct { Name string // the table name Model any // the model of a data object in Go (it's a Go struct). ModelName string // the name of the data model in Go. ModelType reflect.Type // the type of the data model in Go. Fields []*Field // table fields FieldNames []string // the field names in Go. ColumnNames []any // the column names in DB. InsertableColumnNames []any // the insertable column names in DB (remove automatically generated fields). // contains filtered or unexported fields }
Schema represents a table of database
func Parse ¶
Parse a struct to a Schema instance. QEMU Virtual CPU version 2.5+ Benchmark-1 254864 4565 ns/op 2440 B/op 54 allocs/op Benchmark-2 279913 4076 ns/op 2440 B/op 54 allocs/op
func (*Schema) ExtractValues ¶
ExtractValues return the values of object's member variables. QEMU Virtual CPU version 2.5+ Benchmark-1 1606934 746.9 ns/op 184 B/op 11 allocs/op Benchmark-2 1727646 686.2 ns/op 184 B/op 11 allocs/op
type TableNameGetter ¶
type TableNameGetter interface {
GetTableName() string
}
type Tag ¶
type Tag struct { PK bool Auto bool Type string Size string Valid string Column string Default string Comment string }
func NewTag ¶
NewTag parses orm tag to the *Tag. QEMU Virtual CPU version 2.5+ Benchmark-1 1991818 602.9 ns/op 360 B/op 8 allocs/op Benchmark-2 2227740 540.0 ns/op 360 B/op 8 allocs/op
func (*Tag) IsAutoInsertField ¶
IsAutoInsertField checks if the field are automatically generated data