Documentation
¶
Overview ¶
Package modelgo generates the model layer: the entity, its enums, its query types, and the inputs that change it.
It exists because the persistence layer and the API layer were each emitting their own copy of the same row, with a field-by-field conversion between them. Two definitions of one thing is two places to add a column and one place to forget, and the forgetting is silent — the field simply stops being returned.
So there is one definition, in a package both layers import, and no conversion at all. What each layer keeps is what only it can know: how a row is read and written, and how a request becomes one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparableField ¶
func ComparableField(f ir.ResourceField) bool
ComparableField reports whether a column can be ordered.
func FilterFields ¶
func FilterFields(fields []ir.ResourceField, keep func(ir.ResourceField) bool) []ir.ResourceField
FilterFields keeps the fields a predicate accepts.
It is exported because the persistence generator has to select exactly the same fields when it emits the code that renders a query — two answers to "which columns can be compared" would produce a struct field with nowhere to go.
func StringField ¶
func StringField(f ir.ResourceField) bool
StringField reports whether a column can be matched against a pattern.
Types ¶
type Generator ¶
type Generator struct{}
Generator emits the model layer.
func (*Generator) Description ¶
Description implements gen.Generator.