Documentation ¶
Index ¶
- Constants
- Variables
- func AsEnum(t types.Type) (*types.Enum, error)
- func AsEnumInstance(t types.Type, enums enum.Enums) (*enum.Enum, error)
- func AsRef(t types.Type) (*types.Reference, error)
- func DetectLL(msg string, args ...any) string
- func Help(t types.Type, f string, enums enum.Enums) (string, error)
- func ToGoRowType(t types.Type, nullable bool, pkg string, enums enum.Enums, database string) (string, error)
- func ToGoString(t types.Type, prop string, alwaysString bool) string
- func ToGoType(t types.Type, nullable bool, pkg string, enums enum.Enums) (string, error)
- func ToGoViewString(t types.Type, prop string, nullable bool, format string, verbose bool, ...) string
- func ToSQLType(t types.Type) (string, error)
- func TypeToString(t types.Type, prop string) string
- func TypeToViewString(t types.Type, prop string, nullable bool) string
- type Args
- type Column
- func (c *Column) AddTag(t string)
- func (c *Column) BC() string
- func (c *Column) Camel() string
- func (c *Column) CamelPlural() string
- func (c *Column) Clone() *Column
- func (c *Column) HasTag(t string) bool
- func (c *Column) Help(enums enum.Enums) (string, error)
- func (c *Column) NameQuoted() string
- func (c *Column) NeedsErr(_ string, database string) bool
- func (c *Column) Plural() string
- func (c *Column) Proper() string
- func (c *Column) ProperPlural() string
- func (c *Column) RemoveTag(t string)
- func (c *Column) ShouldDisplay(k string) bool
- func (c *Column) Title() string
- func (c *Column) TitleLower() string
- func (c *Column) ToGoEditString(prefix string, format string, id string, enums enum.Enums) (string, error)
- func (c *Column) ToGoMapParse() string
- func (c *Column) ToGoRowType(pkg string, enums enum.Enums, database string) (string, error)
- func (c *Column) ToGoString(prefix string) string
- func (c *Column) ToGoType(pkg string, enums enum.Enums) (string, error)
- func (c *Column) ToGoViewString(prefix string, verbose bool, url bool) string
- func (c *Column) ToSQLType() (string, error)
- func (c *Column) ZeroVal() string
- type Columns
- func (c Columns) Args(pkg string, enums enum.Enums) (string, error)
- func (c Columns) CamelNames() []string
- func (c Columns) ForDisplay(k string) Columns
- func (c Columns) Get(name string) *Column
- func (c Columns) GoRowTypes(pkg string, enums enum.Enums, database string) ([]string, error)
- func (c Columns) GoTypeKeys(pkg string, enums enum.Enums) ([]string, error)
- func (c Columns) GoTypes(pkg string, enums enum.Enums) ([]string, error)
- func (c Columns) HasFormat(f string) bool
- func (c Columns) MaxCamelLength() int
- func (c Columns) MaxGoRowTypeLength(pkg string, enums enum.Enums, database string) int
- func (c Columns) MaxGoTypeLength(pkg string, enums enum.Enums) int
- func (c Columns) Names() []string
- func (c Columns) NamesQuoted() []string
- func (c Columns) NonPKs() Columns
- func (c Columns) OneWithTag(t string) (*Column, error)
- func (c Columns) PKs() Columns
- func (c Columns) ProperNames() []string
- func (c Columns) Refs() string
- func (c Columns) Searches() Columns
- func (c Columns) Smushed() string
- func (c Columns) Titles() []string
- func (c Columns) TitlesLower() []string
- func (c Columns) ToGoStrings(prefix string) string
- func (c Columns) ToRefs(prefix string, relCols ...*Column) string
- func (c Columns) Types() types.Types
- func (c Columns) WhereClause(offset int, placeholder string) string
- func (c Columns) WithTag(t string) Columns
- func (c Columns) WithoutTag(t string) Columns
- func (c Columns) ZeroVals() []string
- type Group
- type Groups
- type HistoryMap
- type Index
- type Indexes
- type Model
- func (m *Model) AddTag(t string)
- func (m *Model) AllSearches(database string) []string
- func (m *Model) Breadcrumbs() string
- func (m *Model) Camel() string
- func (m *Model) CamelPlural() string
- func (m *Model) CanTraverseRelation() bool
- func (m *Model) ClassRef() string
- func (m *Model) FirstLetter() string
- func (m *Model) GroupString(prefix string, dflt string) string
- func (m *Model) GroupedColumns() Columns
- func (m *Model) HasSearches() bool
- func (m *Model) HasTag(t string) bool
- func (m *Model) Help(enums enum.Enums, linebreak string) (string, error)
- func (m *Model) HistoryColumn() *Column
- func (m *Model) HistoryColumns(coreColumns bool) *HistoryMap
- func (m *Model) IconSafe() string
- func (m *Model) IndexedColumns() Columns
- func (m *Model) IsHistory() bool
- func (m *Model) IsRevision() bool
- func (m *Model) IsSoftDelete() bool
- func (m *Model) LastGroup(prefix string, dflt string) string
- func (m *Model) LinkURL(prefix string) string
- func (m *Model) PKs() Columns
- func (m *Model) PackageWithGroup(prefix string) string
- func (m *Model) Plural() string
- func (m *Model) Proper() string
- func (m *Model) ProperPlural() string
- func (m *Model) RelationsFor(col *Column) Relations
- func (m *Model) Route() string
- func (m *Model) SoftDeleteSuffix() string
- func (m *Model) Title() string
- func (m *Model) TitleLower() string
- func (m *Model) TitlePlural() string
- func (m *Model) TitlePluralLower() string
- func (m *Model) URLPath(prefix string) string
- func (m *Model) Validate(mods []string, models Models, groups Groups) error
- type Models
- func (m Models) ForGroup(pth ...string) Models
- func (m Models) Get(n string) *Model
- func (m Models) HasSearch() bool
- func (m Models) HasSeedData() bool
- func (m Models) ReverseRelations(t string) Relations
- func (m Models) Sorted() Models
- func (m Models) SortedDisplay() Models
- func (m Models) Validate(mods []string, groups Groups) error
- type Relation
- func (r *Relation) ContainsSource(colName string) bool
- func (r *Relation) Reverse(name string) *Relation
- func (r *Relation) SrcColumns(m *Model) Columns
- func (r *Relation) SrcQuoted() string
- func (r *Relation) TgtColumns(m *Model) Columns
- func (r *Relation) TgtQuoted() string
- func (r *Relation) WebPath(src *Model, tgt *Model, prefix string) string
- type Relations
Constants ¶
View Source
const ( FmtCode = "code" FmtCodeHidden = "codehidden" FmtCountry = "country" FmtHTML = "html" FmtSelect = "select" FmtSI = "si" FmtURL = "url" )
View Source
const ( HistoryType = "history" RevisionType = "revision" )
Variables ¶
View Source
var ( ExampleColumns = Columns{ {Name: "id", Type: types.NewUUID(), PK: true, Search: true, HelpString: "The primary key"}, {Name: "name", Type: types.NewString(), Search: true, HelpString: "The name of the thing"}, {Name: "created", Type: types.NewTimestamp(), SQLDefault: "now()", Tags: []string{"created"}, HelpString: "Created timestamp"}, {Name: "deleted_at", Type: types.NewTimestamp(), Nullable: true, Tags: []string{"deleted"}, HelpString: "Optional timestamp"}, } ExampleRelations = Relations{ {Name: "relation_a", Src: []string{"parent_id"}, Table: "parent", Tgt: []string{"id"}}, } ExampleIndexes = Indexes{ {Name: "example_idx", Decl: `"table_name" ("id", "created")`}, } Examples = map[string]any{ "columns": ExampleColumns, "relations": ExampleRelations, "indexes": ExampleIndexes, } )
View Source
var ColumnFieldDescs = util.FieldDescs{
{Key: "name", Title: "Name", Description: "The name of the column"},
{Key: "type", Title: "Type", Description: "The type of the column"},
{Key: "pk", Title: "PK", Description: "Indicates if this column is a primary key"},
{Key: "nullable", Title: "Nullable", Description: "Indicates if this column is nullable"},
{Key: "search", Title: "Search", Description: "Indicates if this column is included in search"},
{Key: "indexed", Title: "Indexed", Description: "Indicates if this column is indexed"},
{Key: "display", Title: "Display", Description: "The display setting of the column's value"},
{Key: "format", Title: "Format", Description: "The formatting applied to the column's value"},
{Key: "example", Title: "Example", Description: "Example annotation for the column's value"},
{Key: "validation", Title: "Validation", Description: "Validation annotation for the column's value"},
}
View Source
var IndexFieldDescs = util.FieldDescs{
{Key: "name", Title: "Name", Description: "The name of the index"},
{Key: "decl", Title: "Declaration", Description: "The declaration of the index"},
}
View Source
var RelationFieldDescs = util.FieldDescs{
{Key: "name", Title: "Name", Description: "The name of the relation"},
{Key: "src", Title: "Source", Description: "The source columns of the relation"},
{Key: "table", Title: "Table", Description: "The target table of the relation"},
{Key: "tgt", Title: "Target", Description: "The target columns of the relation"},
}
Functions ¶
func AsEnumInstance ¶ added in v0.6.14
func ToGoRowType ¶ added in v0.7.16
func ToGoViewString ¶
Types ¶
type Args ¶
type Args struct { Config util.ValueMap `json:"config,omitempty"` ConfigFile json.RawMessage `json:"-"` Enums enum.Enums `json:"enums,omitempty"` EnumFiles map[string]json.RawMessage `json:"-"` Models Models `json:"models,omitempty"` ModelFiles map[string]json.RawMessage `json:"-"` Groups Groups `json:"groups,omitempty"` GroupsFile json.RawMessage `json:"-"` Modules []string `json:"-"` Database string `json:"-"` }
func (*Args) DatabaseNow ¶ added in v0.11.28
type Column ¶
type Column struct { Name string `json:"name"` Type *types.Wrapped `json:"type"` PK bool `json:"pk,omitempty"` Nullable bool `json:"nullable,omitempty"` Search bool `json:"search,omitempty"` SQLDefault string `json:"sqlDefault,omitempty"` Indexed bool `json:"indexed,omitempty"` Display string `json:"display,omitempty"` Format string `json:"format,omitempty"` Example string `json:"example,omitempty"` Validation string `json:"validation,omitempty"` Values []string `json:"values,omitempty"` Tags []string `json:"tags,omitempty"` HelpString string `json:"helpString,omitempty"` }
func (*Column) CamelPlural ¶
func (*Column) NameQuoted ¶
func (*Column) ProperPlural ¶
func (*Column) ShouldDisplay ¶
func (*Column) TitleLower ¶
func (*Column) ToGoEditString ¶
func (*Column) ToGoMapParse ¶
func (*Column) ToGoRowType ¶ added in v0.7.16
func (*Column) ToGoString ¶
func (*Column) ToGoViewString ¶
type Columns ¶
type Columns []*Column
func (Columns) CamelNames ¶
func (Columns) ForDisplay ¶
func (Columns) GoRowTypes ¶ added in v0.7.16
func (Columns) GoTypeKeys ¶
func (Columns) MaxCamelLength ¶
func (Columns) MaxGoRowTypeLength ¶ added in v0.7.16
func (Columns) NamesQuoted ¶
func (Columns) ProperNames ¶
func (Columns) TitlesLower ¶
func (Columns) ToGoStrings ¶
func (Columns) WithoutTag ¶
type Group ¶
type HistoryMap ¶
type Index ¶
type Model ¶
type Model struct { Name string `json:"name"` Package string `json:"package"` Group []string `json:"group,omitempty"` Description string `json:"description,omitempty"` Icon string `json:"icon,omitempty"` Ordering filter.Orderings `json:"ordering,omitempty"` SortIndex int `json:"sortIndex,omitempty"` Search []string `json:"search,omitempty"` History string `json:"history,omitempty"` Tags []string `json:"tags,omitempty"` TitleOverride string `json:"title,omitempty"` ProperOverride string `json:"proper,omitempty"` RouteOverride string `json:"route,omitempty"` Config util.ValueMap `json:"config,omitempty"` Columns Columns `json:"columns"` Relations Relations `json:"relations,omitempty"` Indexes Indexes `json:"indexes,omitempty"` SeedData [][]any `json:"seedData,omitempty"` // contains filtered or unexported fields }
func (*Model) AllSearches ¶ added in v0.7.4
func (*Model) Breadcrumbs ¶
func (*Model) CamelPlural ¶
func (*Model) CanTraverseRelation ¶
func (*Model) FirstLetter ¶
func (*Model) GroupedColumns ¶
func (*Model) HasSearches ¶ added in v0.8.25
func (*Model) HistoryColumn ¶
func (*Model) HistoryColumns ¶
func (m *Model) HistoryColumns(coreColumns bool) *HistoryMap
func (*Model) IndexedColumns ¶ added in v0.6.20
func (*Model) IsRevision ¶
func (*Model) IsSoftDelete ¶
func (*Model) PackageWithGroup ¶
func (*Model) ProperPlural ¶
func (*Model) RelationsFor ¶
func (*Model) SoftDeleteSuffix ¶
func (*Model) TitleLower ¶
func (*Model) TitlePlural ¶
func (*Model) TitlePluralLower ¶
type Models ¶
type Models []*Model
func (Models) HasSeedData ¶
func (Models) ReverseRelations ¶
func (Models) SortedDisplay ¶ added in v0.11.9
type Relation ¶
type Relation struct { Name string `json:"name"` Src []string `json:"src"` Table string `json:"table"` Tgt []string `json:"tgt"` }
func (*Relation) ContainsSource ¶ added in v0.6.20
func (*Relation) SrcColumns ¶
func (*Relation) TgtColumns ¶
Click to show internal directories.
Click to hide internal directories.