Documentation
¶
Overview ¶
Package codegen provides model generation from database schema.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conflict ¶
type Conflict struct {
Key string // constant suffix, e.g. "TenantIDEmail"
Value string // CONFLICT (tenant_id, email) DO UPDATE
}
Conflict is an upsert conflict target of the generated model.
type Excluded ¶
type Excluded struct {
Key string // constant suffix, e.g. "Subject"
Value string // subject = EXCLUDED.subject
}
Excluded is one assignment for the SET clause of an upsert.
type Field ¶
type Field struct {
Imports []Import // imports required by the field type
Name string // field name, e.g: ID
Type string // type, e.g: string | int32 | int8
Tag string // tag, e.g: `bun:"id,pk,autoincrement,notnull" json:"id,omitempty"`
Comments []string // comments e.g: user id
ColumnName string // db column name e.g: id
Kind string // logic type: NUMERIC |STRING | ...
IsArithmetic bool // arithmetic expressions make sense for the field
IsPrimary bool // is primary key
IsNullable bool // is nullable
IsCustom bool // is custom type
IsRelation bool // is relation
}
func NewCustomField ¶
type Model ¶
type Model struct {
Version string // bake version
Module string // module path
Package string // package name
Imports [][]Import // imports
Driver string // driver name
BunModel string // bun.BaseModel
Table string // table name
Model string // model name
Alias string // model alias
Comments []string // model comments
Fields []*Field // fields
Indexes []Index // indexes
Conflicts []Conflict // upsert conflict targets
Excluded []Excluded // upsert SET assignments
Timezone string // timezone
CreatedAtType string // created_at type
UpdatedAtType string // updated_at type
DeletedAtType string // deleted_at type
HasField bool // has at least one field
HasNullable bool // has a nullable field
HasString bool // has a STRING field
HasOrdered bool // has an ordered field (string/numeric/time)
HasOrderedNonString bool // has a numeric or time field
HasEquatable bool // has an equatable field (numeric/string/bool/time/enum)
HasRelation bool // has a relation field
HasArithmetic bool // has a non-primary numeric field
HasTime bool // has a TIME field
}
func NewCustomStruct ¶
func NewCustomStruct(cfg *config.Config, st *config.CustomStruct) *Model
NewCustomStruct creates Model from a single custom struct configuration.
Click to show internal directories.
Click to hide internal directories.