Documentation
¶
Overview ¶
Package ir defines the resolved intermediate representation (IR) of a GCORM schema. The IR is produced by the resolve stage and consumed by code generators.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Datasource ¶
type Datasource struct {
Name string
Provider string // "postgresql", "mysql", "sqlite"
URL string // raw URL or env() reference
URLIsEnv bool // true if URL comes from env()
EnvVar string // environment variable name if URLIsEnv
Schema string // database schema/namespace
Span ast.Span
}
Datasource holds the resolved database connection configuration.
type DefaultValue ¶
type DefaultValue struct {
IsFunction bool
FuncName string // e.g. "uuid", "now", "autoincrement"
FuncArgs []string
Value string // literal value for non-function defaults
IsString bool
IsNumber bool
IsBool bool
}
DefaultValue holds the resolved @default value for a field.
type DialectType ¶
DialectType holds dialect-specific type information.
type Field ¶
type Field struct {
Name string
DBName string // from @map, defaults to field name
Type FieldKind
ScalarType string // "String", "Int", etc. for scalar fields
EnumType string // enum name for enum fields
ModelType string // model name for relation fields
IsOptional bool
IsList bool
IsID bool // has @id
IsUnique bool // has @unique
IsUpdatedAt bool // has @updatedAt
Default *DefaultValue
NativeType *NativeType // from @db.*
Span ast.Span
}
Field holds the resolved definition of a single model field.
type GenerationManifest ¶
type GenerationManifest struct {
SchemaFiles []string
Models []string
Enums []string
Generator string
Output string
Package string
}
GenerationManifest records what was generated and from what.
type Generator ¶
type Generator struct {
Name string
Provider string
Output string
Package string
EmitRuntime bool
Span ast.Span
}
Generator holds the resolved code generation configuration.
type Model ¶
type Model struct {
Name string
DBName string // from @@map, defaults to model name
Schema string // from @@schema
Fields []*Field
Relations []*Relation
Indexes []*Index
PrimaryKey *PrimaryKey
UniqueConstraints []*UniqueConstraint
Span ast.Span
}
Model holds the resolved definition of a data model.
func (*Model) ScalarFields ¶
ScalarFields returns only non-relation fields.
type NativeType ¶
NativeType holds a provider-specific type annotation from @db.*.
type PrimaryKey ¶
PrimaryKey holds the resolved primary key for a model.
type Relation ¶
type Relation struct {
Name string // relation name (optional)
Field *Field // the field that declared @relation
Type RelationType
FromModel string
ToModel string
Fields []string // local fields (from `fields:`)
References []string // remote fields (from `references:`)
OnDelete string
OnUpdate string
}
Relation holds the resolved relationship between two models.
type RelationType ¶
type RelationType int
RelationType classifies the cardinality of a relation.
const ( RelationOneToOne RelationType = iota RelationOneToMany RelationManyToOne RelationManyToMany )
type Schema ¶
type Schema struct {
Datasource *Datasource
Generators []*Generator
Models []*Model
Enums []*Enum
}
Schema is the fully resolved schema graph, the output of the compiler pipeline.
type UniqueConstraint ¶
UniqueConstraint holds a resolved model-level unique constraint (@@unique).