Documentation
¶
Index ¶
- func FieldTypeToGoType(ft model.FieldType, ref string) string
- func ToSnakeCase(s string) string
- type FieldInfo
- type Generator
- func (g *Generator) ExportSQL(root string, exporter ddl.Exporter) (string, error)
- func (o *Generator) GenerateForFile(infos []StructInfo, sourceFile string) error
- func (g *Generator) GenerateForStruct(structName string, goFile string) error
- func (g *Generator) MainInputFileRelativePath() string
- func (g *Generator) Name() string
- func (g *Generator) NewFileEvent(fileName, extension, filePath, event string) error
- func (g *Generator) Run() error
- func (g *Generator) ScanModules(rootDir string) error
- func (g *Generator) SetFinder(f *modfind.Finder)
- func (g *Generator) SetLog(fn func(messages ...any))
- func (g *Generator) SetRootDir(dir string)
- func (g *Generator) SetSkipTidy(skip bool)
- func (g *Generator) SetSyncer(s SchemaSyncer)
- func (g *Generator) SupportedExtensions() []string
- func (g *Generator) UnobservedFiles() []string
- type SchemaSyncer
- type StructInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FieldTypeToGoType ¶ added in v0.9.23
func ToSnakeCase ¶ added in v0.9.23
Types ¶
type FieldInfo ¶
type FieldInfo struct {
Name string
ColumnName string
Type model.FieldType
PK bool
Unique bool
NotNull bool
AutoInc bool
Ref string
RefColumn string
OnDelete string
IsPK bool
OldName string
GoType string
IsPointer bool // true if the original field is *T (only meaningful for FieldStruct)
OmitEmpty bool
Exclude bool
HasDB bool
// Permitted config — populated from validate:"..." tag
Letters bool
Tilde bool
Numbers bool
Spaces bool
Extra []rune
Minimum int
Maximum int
WidgetConstructor string // e.g. "input.Text()"
Tags []string // input modifiers e.g. "notilde", "min=2"
}
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Ormc is the code generator handler for the ormc tool.
func (*Generator) ExportSQL ¶ added in v0.9.18
ExportSQL scans the directory for models and returns the full DDL. Requires an injected ddl.Exporter (e.g. from sqlt or postgres).
func (*Generator) GenerateForFile ¶
func (o *Generator) GenerateForFile(infos []StructInfo, sourceFile string) error
GenerateForFile writes ORM implementations for all infos into one file.
func (*Generator) GenerateForStruct ¶
GenerateForStruct reads the Go File and generates the ORM implementations for a given struct name.
func (*Generator) MainInputFileRelativePath ¶
MainInputFileRelativePath returns the relative path to the main input file, if any.
func (*Generator) Name ¶ added in v0.9.4
Name returns the TUI handler label shown in the development console.
func (*Generator) NewFileEvent ¶
NewFileEvent implements the file-event contract for watchers (e.g. tinywasm/app's devwatch).
func (*Generator) ScanModules ¶
ScanModules syncs the DB schema of every discovered module to the injected SchemaSyncer. Called once at startup by the tool (app), after SetSyncer.
- Writable module (main / replace): regenerate <file>_orm.go from model.go, then sync each DB struct.
- Read-only module (cache): parse the committed model_orm.go, then sync.
No-op if no syncer is injected (CLI codegen-only path).
func (*Generator) SetFinder ¶
SetFinder injects the shared modfind.Finder (one go list across ssr/image/ormc).
func (*Generator) SetLog ¶
SetLog sets the log function for warnings and informational messages. If not set, messages are silently discarded.
func (*Generator) SetRootDir ¶
SetRootDir sets the root directory that Run() will scan. Defaults to ".". Useful in tests to point to a specific directory without needing os.Chdir.
func (*Generator) SetSkipTidy ¶
SetSkipTidy enables or disables the go mod tidy pass.
func (*Generator) SetSyncer ¶
func (g *Generator) SetSyncer(s SchemaSyncer)
SetSyncer sets the schema syncer for the generator.
func (*Generator) SupportedExtensions ¶
SupportedExtensions returns the list of file extensions this generator handles.
func (*Generator) UnobservedFiles ¶
UnobservedFiles returns a list of files that should be ignored by the watcher.
type SchemaSyncer ¶
SchemaSyncer applies a parsed table schema. Implemented by the consumer (tinywasm/app) over *orm.DB; ormc only ever sees this interface.