models

package
v1.33.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package models provides proto model annotation parsing, code generation, and ORM integration for buffalo.models.

It generates typed model classes / structs for Go, Python, C++, and Rust from protobuf messages annotated with [(buffalo.models.model)] and [(buffalo.models.field)]. The generation output varies depending on the configured ORM plugin (e.g. pydantic, sqlalchemy, gorm, diesel).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckORMDependencies

func CheckORMDependencies(lang, ormRaw string) []string

CheckORMDependencies validates that ORM dependencies are available.

func ExtractSyntax added in v1.21.4

func ExtractSyntax(content string) string

ExtractSyntax returns the syntax version declared in the proto file (e.g. "proto3"). Returns an empty string if no syntax declaration is found.

func GenerateModels

func GenerateModels(protoFiles []string, lang, ormRaw, outputDir, pkg, pb2ImportPrefix string, fromProto ...bool) ([]string, error)

GenerateModels is a standalone entry point for the CLI. It reads proto files, parses models, and generates code for the specified language. When fromProto is true, ALL messages are extracted (not just annotated ones). pb2ImportPrefix is an optional dotted prefix prepended to pb2 imports (Python only).

func NewModelsPlugin

func NewModelsPlugin(log *logger.Logger) plugin.Plugin

NewModelsPlugin creates a new ModelsPlugin instance.

Types

type CheckDef

type CheckDef struct {
	Name       string
	Expression string
}

CheckDef describes a CHECK constraint.

type CppNoneGenerator

type CppNoneGenerator struct{}

CppNoneGenerator generates plain C++ structs with optional JSON serialization.

func (*CppNoneGenerator) GenerateBaseModel

func (g *CppNoneGenerator) GenerateBaseModel(_ GenerateOptions) (GeneratedFile, error)

func (*CppNoneGenerator) GenerateEnum added in v1.21.4

func (g *CppNoneGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*CppNoneGenerator) GenerateInit

func (g *CppNoneGenerator) GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)

func (*CppNoneGenerator) GenerateModel

func (g *CppNoneGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*CppNoneGenerator) Language

func (g *CppNoneGenerator) Language() string

func (*CppNoneGenerator) ORMName

func (g *CppNoneGenerator) ORMName() string

type EnumDef added in v1.21.2

type EnumDef struct {
	Name    string      // enum type name
	Comment string      // leading comment / docstring
	Values  []EnumValue // enum constants
}

EnumDef describes a proto enum extracted from a message or top-level scope.

func ExtractTopLevelEnums added in v1.21.4

func ExtractTopLevelEnums(content, filePath string) []EnumDef

ExtractTopLevelEnums scans a proto file and extracts top-level enum definitions (those outside of any message block).

type EnumValue added in v1.21.2

type EnumValue struct {
	Name    string
	Number  int32
	Comment string // inline or leading comment
}

EnumValue describes a single enum constant.

type FieldBehavior

type FieldBehavior int

FieldBehavior mirrors the proto enum FieldBehavior.

const (
	BehaviorDefault    FieldBehavior = 0
	BehaviorReadOnly   FieldBehavior = 1
	BehaviorWriteOnly  FieldBehavior = 2
	BehaviorImmutable  FieldBehavior = 3
	BehaviorComputed   FieldBehavior = 4
	BehaviorVirtual    FieldBehavior = 5
	BehaviorOutputOnly FieldBehavior = 6
	BehaviorInputOnly  FieldBehavior = 7
)

func (FieldBehavior) String

func (b FieldBehavior) String() string

type FieldDef

type FieldDef struct {
	// Proto source
	Name      string // proto field name (snake_case)
	ProtoType string // proto type (string, int32, etc.)
	Number    int    // proto field number
	Repeated  bool   // repeated field

	// Map field support: map<KeyType, ValueType>
	IsMap        bool   // true when the field is a proto map
	MapKeyType   string // key type for map fields (e.g. "string")
	MapValueType string // value type for map fields (e.g. "string")

	// Oneof support
	OneofGroup string // name of the oneof group this field belongs to

	// Enum support
	IsEnum       bool   // true when the field type is a proto enum
	EnumTypeName string // original enum type name (e.g. "SourceStatus")

	// From [(buffalo.models.field)]
	Alias             string
	Description       string
	PrimaryKey        bool
	AutoIncrement     bool
	Nullable          bool
	Unique            bool
	DefaultValue      string
	MaxLength         int32
	MinLength         int32
	Precision         int32
	Scale             int32
	CustomType        string
	DBType            string
	Visibility        FieldVisibility
	Behavior          FieldBehavior
	Sensitive         bool
	Deprecated        bool
	DeprecatedMessage string
	Index             bool
	IndexType         IndexType
	JSONName          string
	XMLName           string
	OmitEmpty         bool
	Relation          *RelationDef
	Example           string
	Comment           string
	AutoGenerate      bool
	AutoNow           bool
	AutoNowAdd        bool
	Sequence          string
	Collation         string
	Ignore            bool
	DBIgnore          bool
	APIIgnore         bool
	Tags              []string
	Metadata          map[string]string
}

FieldDef represents a parsed field within a model.

func (*FieldDef) EffectiveJSONName

func (f *FieldDef) EffectiveJSONName() string

EffectiveJSONName returns the serialization name for JSON.

func (*FieldDef) IsPersistable

func (f *FieldDef) IsPersistable() bool

IsPersistable returns true if the field should be included in DB operations.

func (*FieldDef) IsSerializable

func (f *FieldDef) IsSerializable() bool

IsSerializable returns true if the field should be included in serialization.

type FieldVisibility

type FieldVisibility int

FieldVisibility mirrors the proto enum FieldVisibility.

const (
	VisibilityDefault   FieldVisibility = 0
	VisibilityPublic    FieldVisibility = 1
	VisibilityInternal  FieldVisibility = 2
	VisibilityExternal  FieldVisibility = 3
	VisibilityPrivate   FieldVisibility = 4
	VisibilityProtected FieldVisibility = 5
)

func (FieldVisibility) String

func (v FieldVisibility) String() string

type GenerateOptions

type GenerateOptions struct {
	// Language target (go, python, cpp, rust).
	Language string

	// ORM plugin to use.
	ORM ORMPlugin

	// Output directory for generated models.
	OutputDir string

	// Package / module name.
	Package string

	// Pb2ImportPrefix is the dotted Python module prefix prepended to pb2 imports.
	// Example: "araviec_apis.generated.python" produces
	//   from araviec_apis.generated.python.araviec.common.v1.msg_pb2 import ...
	// When empty, proto file paths are used as-is (no prefix).
	Pb2ImportPrefix string

	// BaseModelFields — extra fields injected into BaseModel.
	BaseModelFields []FieldDef

	// GenerateBaseModel — whether to emit a BaseModel class/struct.
	GenerateBaseModel bool

	// GenerateInit — generate __init__.py for Python.
	GenerateInit bool

	// FixImports — fix relative imports for Python.
	FixImports bool

	// PreserveProtoStructure — mirror proto directory structure.
	PreserveProtoStructure bool

	// Verbose — emit extra comments in generated code.
	Verbose bool
}

GenerateOptions controls the code generation process.

type GeneratedFile

type GeneratedFile struct {
	Path    string // Relative output path (e.g. "models/user.py")
	Content string // Generated source code
}

GeneratedFile represents a single generated source file.

type GoGORMGenerator

type GoGORMGenerator struct{}

GoGORMGenerator generates GORM-tagged Go structs.

func (*GoGORMGenerator) GenerateBaseModel

func (g *GoGORMGenerator) GenerateBaseModel(opts GenerateOptions) (GeneratedFile, error)

func (*GoGORMGenerator) GenerateEnum added in v1.21.4

func (g *GoGORMGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*GoGORMGenerator) GenerateInit

func (g *GoGORMGenerator) GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)

func (*GoGORMGenerator) GenerateModel

func (g *GoGORMGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*GoGORMGenerator) Language

func (g *GoGORMGenerator) Language() string

func (*GoGORMGenerator) ORMName

func (g *GoGORMGenerator) ORMName() string

type GoNoneGenerator

type GoNoneGenerator struct{}

GoNoneGenerator generates plain Go structs with json tags.

func (*GoNoneGenerator) GenerateBaseModel

func (g *GoNoneGenerator) GenerateBaseModel(opts GenerateOptions) (GeneratedFile, error)

func (*GoNoneGenerator) GenerateEnum added in v1.21.4

func (g *GoNoneGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*GoNoneGenerator) GenerateInit

func (g *GoNoneGenerator) GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)

func (*GoNoneGenerator) GenerateModel

func (g *GoNoneGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*GoNoneGenerator) Language

func (g *GoNoneGenerator) Language() string

func (*GoNoneGenerator) ORMName

func (g *GoNoneGenerator) ORMName() string

type GoSQLXGenerator

type GoSQLXGenerator struct{}

GoSQLXGenerator generates Go structs with db tags for sqlx.

func (*GoSQLXGenerator) GenerateBaseModel

func (g *GoSQLXGenerator) GenerateBaseModel(opts GenerateOptions) (GeneratedFile, error)

func (*GoSQLXGenerator) GenerateEnum added in v1.21.4

func (g *GoSQLXGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*GoSQLXGenerator) GenerateInit

func (g *GoSQLXGenerator) GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)

func (*GoSQLXGenerator) GenerateModel

func (g *GoSQLXGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*GoSQLXGenerator) Language

func (g *GoSQLXGenerator) Language() string

func (*GoSQLXGenerator) ORMName

func (g *GoSQLXGenerator) ORMName() string

type IndexDef

type IndexDef struct {
	Name    string
	Columns []string
	Unique  bool
	Type    IndexType
	Where   string // partial index condition
	Comment string
}

IndexDef describes a composite index.

type IndexType

type IndexType int

IndexType defines index algorithm.

const (
	IndexDefault IndexType = 0
	IndexBTree   IndexType = 1
	IndexHash    IndexType = 2
	IndexGIN     IndexType = 3
	IndexGIST    IndexType = 4
	IndexBRIN    IndexType = 5
)

func (IndexType) String

func (t IndexType) String() string

type ModelCodeGenerator

type ModelCodeGenerator interface {
	// Language returns the target language identifier ("go", "python", etc.).
	Language() string

	// ORMName returns the ORM / framework name ("None", "pydantic", "gorm", etc.).
	ORMName() string

	// GenerateBaseModel produces the base model class / struct.
	GenerateBaseModel(opts GenerateOptions) (GeneratedFile, error)

	// GenerateModel produces a single model file from a ModelDef.
	GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

	// GenerateEnum produces source for a standalone enum definition.
	// Returns empty file if enums are emitted inline within GenerateModel.
	GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

	// GenerateInit produces __init__.py or mod.rs or similar index file.
	// May return empty file if not applicable for the language.
	GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)
}

ModelCodeGenerator generates model source code for a target language + ORM.

func NewModelCodeGenerator

func NewModelCodeGenerator(language string, orm ORMPlugin) (ModelCodeGenerator, error)

NewModelCodeGenerator creates a code generator for the given language + ORM.

type ModelDef

type ModelDef struct {
	// Proto source
	MessageName string // original proto message name
	Package     string // proto package (e.g. "myservice")
	FilePath    string // source .proto file path

	// Model-level options (from [(buffalo.models.model)])
	Name              string   // class/struct name override
	TableName         string   // optional DB table name
	Schema            string   // optional DB schema
	Description       string   // docstring
	Tags              []string // arbitrary tags
	Abstract          bool     // abstract model
	Extends           string   // parent model name
	Mixins            []string // mixin model names
	SoftDelete        bool     // add deleted_at
	Timestamps        bool     // add created_at / updated_at
	Deprecated        bool     // deprecated model
	DeprecatedMessage string
	Generate          []string // what to generate: "model", "repo", "factory"

	// Composite constraints
	Indexes []IndexDef
	Uniques []UniqueDef
	Checks  []CheckDef

	// Nested enums within this message
	Enums []EnumDef

	// Oneof groups within this message
	Oneofs []OneofDef

	// Nested messages (sub-structs) within this message
	NestedMessages []ModelDef

	// Fields (ordered)
	Fields []FieldDef
}

ModelDef represents a parsed model definition from a proto message.

func ExtractAllMessages added in v1.21.2

func ExtractAllMessages(content, filePath string) ([]ModelDef, error)

ExtractAllMessages scans a full proto file text and returns ModelDefs for every message found. Non-annotated messages automatically

Service definitions are skipped. Nested enums are extracted into ModelDef.Enums. map<K,V> fields are represented with IsMap=true, MapKeyType, MapValueType.

func ExtractModels

func ExtractModels(content, filePath string) ([]ModelDef, error)

ExtractModels scans a full proto file text and returns ModelDefs for every message that has a [(buffalo.models.model)] annotation.

func ListModelAnnotations

func ListModelAnnotations(protoFiles []string, fromProto ...bool) ([]ModelDef, error)

ListModelAnnotations scans proto files and returns parsed ModelDef without generating. When fromProto is true, ALL messages are returned (not just annotated ones).

func (*ModelDef) EffectiveName

func (m *ModelDef) EffectiveName() string

EffectiveName returns the model name: Name override or MessageName.

type ModelsPlugin

type ModelsPlugin struct {
	// contains filtered or unexported fields
}

ModelsPlugin implements plugin.Plugin and generates typed code models from buffalo.models annotations in proto files.

func (*ModelsPlugin) Description

func (p *ModelsPlugin) Description() string

func (*ModelsPlugin) Execute

func (p *ModelsPlugin) Execute(ctx context.Context, input *plugin.Input) (*plugin.Output, error)

Execute parses proto files for buffalo.models annotations and generates model source code for each enabled language.

func (*ModelsPlugin) Init

func (p *ModelsPlugin) Init(cfg plugin.Config) error

func (*ModelsPlugin) Name

func (p *ModelsPlugin) Name() string

func (*ModelsPlugin) Shutdown

func (p *ModelsPlugin) Shutdown() error

func (*ModelsPlugin) Type

func (p *ModelsPlugin) Type() plugin.PluginType

func (*ModelsPlugin) Version

func (p *ModelsPlugin) Version() string

type ORMPlugin

type ORMPlugin struct {
	Name    string // "None", "pydantic", "sqlalchemy", "gorm", "diesel", etc.
	Version string // optional required version (e.g. "2.0")
}

ORMPlugin describes which ORM framework to use for generation.

func ParseORMPlugin

func ParseORMPlugin(s string) ORMPlugin

ParseORMPlugin parses "plugin_name[@version]" notation.

Examples:

"default"       → {Name: "None", Version: ""}
"None"          → {Name: "None", Version: ""}
"pydantic"      → {Name: "pydantic", Version: ""}
"pydantic@2.0"  → {Name: "pydantic", Version: "2.0"}
""              → {Name: "None", Version: ""}

func (ORMPlugin) IsNone

func (p ORMPlugin) IsNone() bool

IsNone returns true for "None" / "default" / empty.

func (ORMPlugin) String

func (p ORMPlugin) String() string

String formats the plugin back to "name[@version]".

type OnAction

type OnAction int

OnAction mirrors referential integrity actions.

const (
	ActionUnspecified OnAction = 0
	ActionCascade     OnAction = 1
	ActionSetNull     OnAction = 2
	ActionSetDefault  OnAction = 3
	ActionRestrict    OnAction = 4
	ActionNoAction    OnAction = 5
)

func (OnAction) String

func (a OnAction) String() string

type OneofDef added in v1.21.4

type OneofDef struct {
	Name    string     // oneof group name
	Comment string     // leading comment / docstring
	Fields  []FieldDef // fields within the oneof
}

OneofDef describes a proto oneof group within a message.

type ProtoFileOption added in v1.21.4

type ProtoFileOption struct {
	Name  string
	Value string
}

ProtoFileOption represents a file-level option (e.g. option go_package = "...";).

func ExtractFileOptions added in v1.21.4

func ExtractFileOptions(content string) []ProtoFileOption

ExtractFileOptions returns all file-level option declarations.

type ProtoImport added in v1.21.4

type ProtoImport struct {
	Path     string // e.g. "google/protobuf/any.proto"
	Modifier string // "weak", "public", or ""
}

ProtoImport represents a single import statement in a proto file.

func ExtractImports added in v1.21.4

func ExtractImports(content string) []ProtoImport

ExtractImports returns all import statements found in the proto file.

type PythonNoneGenerator

type PythonNoneGenerator struct{}

PythonNoneGenerator generates pure Python dataclasses.

func (*PythonNoneGenerator) GenerateBaseModel

func (g *PythonNoneGenerator) GenerateBaseModel(opts GenerateOptions) (GeneratedFile, error)

func (*PythonNoneGenerator) GenerateEnum added in v1.21.4

func (g *PythonNoneGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*PythonNoneGenerator) GenerateInit

func (g *PythonNoneGenerator) GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)

func (*PythonNoneGenerator) GenerateModel

func (g *PythonNoneGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*PythonNoneGenerator) Language

func (g *PythonNoneGenerator) Language() string

func (*PythonNoneGenerator) ORMName

func (g *PythonNoneGenerator) ORMName() string

type PythonPydanticGenerator

type PythonPydanticGenerator struct {
	// contains filtered or unexported fields
}

PythonPydanticGenerator uses pydantic BaseModel.

func (*PythonPydanticGenerator) GenerateBaseModel

func (g *PythonPydanticGenerator) GenerateBaseModel(opts GenerateOptions) (GeneratedFile, error)

func (*PythonPydanticGenerator) GenerateEnum added in v1.21.4

func (g *PythonPydanticGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*PythonPydanticGenerator) GenerateInit

func (g *PythonPydanticGenerator) GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)

func (*PythonPydanticGenerator) GenerateModel

func (g *PythonPydanticGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*PythonPydanticGenerator) Language

func (g *PythonPydanticGenerator) Language() string

func (*PythonPydanticGenerator) ORMName

func (g *PythonPydanticGenerator) ORMName() string

type PythonSQLAlchemyGenerator

type PythonSQLAlchemyGenerator struct {
	// contains filtered or unexported fields
}

PythonSQLAlchemyGenerator generates SQLAlchemy ORM models.

func (*PythonSQLAlchemyGenerator) GenerateBaseModel

func (g *PythonSQLAlchemyGenerator) GenerateBaseModel(opts GenerateOptions) (GeneratedFile, error)

func (*PythonSQLAlchemyGenerator) GenerateEnum added in v1.21.4

func (g *PythonSQLAlchemyGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*PythonSQLAlchemyGenerator) GenerateInit

func (g *PythonSQLAlchemyGenerator) GenerateInit(models []ModelDef, opts GenerateOptions) (GeneratedFile, error)

func (*PythonSQLAlchemyGenerator) GenerateModel

func (g *PythonSQLAlchemyGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*PythonSQLAlchemyGenerator) Language

func (g *PythonSQLAlchemyGenerator) Language() string

func (*PythonSQLAlchemyGenerator) ORMName

func (g *PythonSQLAlchemyGenerator) ORMName() string

type RelationDef

type RelationDef struct {
	Type       RelationType
	Model      string // target model name
	ForeignKey string
	References string // default "id"
	JoinTable  string // for many_to_many
	OnDelete   OnAction
	OnUpdate   OnAction
	Eager      bool
	Through    string // intermediate model
	InverseOf  string // inverse relation field
}

RelationDef describes a relationship between models.

type RelationType

type RelationType int

RelationType mirrors the proto enum RelationType.

const (
	RelationUnspecified RelationType = 0
	RelationBelongsTo   RelationType = 1
	RelationHasOne      RelationType = 2
	RelationHasMany     RelationType = 3
	RelationManyToMany  RelationType = 4
)

func (RelationType) String

func (r RelationType) String() string

type RustDieselGenerator

type RustDieselGenerator struct {
	// contains filtered or unexported fields
}

RustDieselGenerator generates Diesel-annotated Rust structs.

func (*RustDieselGenerator) GenerateBaseModel

func (g *RustDieselGenerator) GenerateBaseModel(_ GenerateOptions) (GeneratedFile, error)

func (*RustDieselGenerator) GenerateEnum added in v1.21.4

func (g *RustDieselGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*RustDieselGenerator) GenerateInit

func (g *RustDieselGenerator) GenerateInit(models []ModelDef, _ GenerateOptions) (GeneratedFile, error)

func (*RustDieselGenerator) GenerateModel

func (g *RustDieselGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*RustDieselGenerator) Language

func (g *RustDieselGenerator) Language() string

func (*RustDieselGenerator) ORMName

func (g *RustDieselGenerator) ORMName() string

type RustNoneGenerator

type RustNoneGenerator struct{}

RustNoneGenerator generates plain Rust structs with serde derives.

func (*RustNoneGenerator) GenerateBaseModel

func (g *RustNoneGenerator) GenerateBaseModel(_ GenerateOptions) (GeneratedFile, error)

func (*RustNoneGenerator) GenerateEnum added in v1.21.4

func (g *RustNoneGenerator) GenerateEnum(enum EnumDef, opts GenerateOptions) (GeneratedFile, error)

func (*RustNoneGenerator) GenerateInit

func (g *RustNoneGenerator) GenerateInit(models []ModelDef, _ GenerateOptions) (GeneratedFile, error)

func (*RustNoneGenerator) GenerateModel

func (g *RustNoneGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*RustNoneGenerator) Language

func (g *RustNoneGenerator) Language() string

func (*RustNoneGenerator) ORMName

func (g *RustNoneGenerator) ORMName() string

type TypescriptNoneGenerator added in v1.22.0

type TypescriptNoneGenerator struct{}

TypescriptNoneGenerator generates plain TypeScript interfaces.

func (*TypescriptNoneGenerator) GenerateBaseModel added in v1.22.0

func (g *TypescriptNoneGenerator) GenerateBaseModel(_ GenerateOptions) (GeneratedFile, error)

func (*TypescriptNoneGenerator) GenerateEnum added in v1.22.0

func (*TypescriptNoneGenerator) GenerateInit added in v1.22.0

func (g *TypescriptNoneGenerator) GenerateInit(models []ModelDef, _ GenerateOptions) (GeneratedFile, error)

func (*TypescriptNoneGenerator) GenerateModel added in v1.22.0

func (g *TypescriptNoneGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*TypescriptNoneGenerator) Language added in v1.22.0

func (g *TypescriptNoneGenerator) Language() string

func (*TypescriptNoneGenerator) ORMName added in v1.22.0

func (g *TypescriptNoneGenerator) ORMName() string

type TypescriptZodGenerator added in v1.22.0

type TypescriptZodGenerator struct{}

TypescriptZodGenerator generates TypeScript models with Zod schemas.

func (*TypescriptZodGenerator) GenerateBaseModel added in v1.22.0

func (g *TypescriptZodGenerator) GenerateBaseModel(_ GenerateOptions) (GeneratedFile, error)

func (*TypescriptZodGenerator) GenerateEnum added in v1.22.0

func (*TypescriptZodGenerator) GenerateInit added in v1.22.0

func (g *TypescriptZodGenerator) GenerateInit(models []ModelDef, _ GenerateOptions) (GeneratedFile, error)

func (*TypescriptZodGenerator) GenerateModel added in v1.22.0

func (g *TypescriptZodGenerator) GenerateModel(model ModelDef, opts GenerateOptions) ([]GeneratedFile, error)

func (*TypescriptZodGenerator) Language added in v1.22.0

func (g *TypescriptZodGenerator) Language() string

func (*TypescriptZodGenerator) ORMName added in v1.22.0

func (g *TypescriptZodGenerator) ORMName() string

type UniqueDef

type UniqueDef struct {
	Name    string
	Columns []string
}

UniqueDef describes a composite unique constraint.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL