Documentation
¶
Overview ¶
Package orm owns the compiler-side integration for the official trb/orm package. The compiler pipeline transports its declarations and IR manifest without depending on database adapters or ORM semantics.
Index ¶
- Constants
- func AggregateOperations() []string
- func AggregateResultType(operation string, column Column) (types.Type, bool)
- func Declarations(programs []*ast.Program, projectRoot string, options map[string][]byte) (*declaration.Catalog, error)
- func EnumMemberStorageName(name string) string
- func TableName(model string) string
- type Adapter
- type Association
- type AssociationKind
- type Column
- type Config
- type DependentAction
- type EnumColumn
- type EnumColumnValue
- type ExplainStyle
- type ForeignKey
- type Introspector
- type Manifest
- func (m *Manifest) Augment(program *ir.Program)
- func (m *Manifest) ChangesModel(name string) (Model, bool)
- func (m *Manifest) DraftModel(name string) (Model, bool)
- func (m *Manifest) EnumColumnsForModule(module string) []*EnumColumn
- func (*Manifest) ExtensionName() string
- func (m *Manifest) GroupModel(name string) (Model, Column, bool)
- func (m *Manifest) Model(name string) (Model, bool)
- func (m *Manifest) ModelsForModule(modulePath string) []Model
- func (m *Manifest) QueryModel(name string) (Model, bool)
- func (m *Manifest) ScopeModel(name string) (Model, bool)
- type Model
- func (m Model) Association(name string) (Association, bool)
- func (m Model) BatchKey() (Column, bool)
- func (m Model) ChangesType() string
- func (m Model) Column(name string) (Column, bool)
- func (m Model) DraftType() string
- func (m Model) GroupType(column Column) string
- func (m Model) PrimaryKey() (Column, bool)
- func (m Model) ScopeType() string
- type Operator
- type Predicate
- type Schema
- type Table
- type UniqueConstraint
Constants ¶
View Source
const ( PackageName = "trb/orm" TypeProvider = "trb.orm" ProjectProvider = "trb.orm.schema" )
Variables ¶
This section is empty.
Functions ¶
func AggregateOperations ¶
func AggregateOperations() []string
func AggregateResultType ¶
func Declarations ¶
func EnumMemberStorageName ¶ added in v0.2.2
Types ¶
type Adapter ¶
type Adapter struct {
Name string
DriverName string
GoDriverImport string
IdentifierMark string
NumberedBinds bool
ExplainStyle ExplainStyle
OffsetNoLimit string
InsertReturning bool
DefaultInsert string
}
Adapter describes the database-specific behavior shared by schema introspection and backend runtime generation.
func AdapterFor ¶
func (Adapter) Placeholder ¶
func (Adapter) QuoteIdentifier ¶
type Association ¶
type AssociationKind ¶
type AssociationKind string
const ( BelongsTo AssociationKind = "belongs_to" HasMany AssociationKind = "has_many" HasOne AssociationKind = "has_one" )
type DependentAction ¶
type DependentAction string
const ( DependentDestroy DependentAction = "destroy" DependentDelete DependentAction = "delete" DependentNullify DependentAction = "nullify" DependentRestrict DependentAction = "restrict" )
type EnumColumn ¶ added in v0.2.2
type EnumColumn struct {
Name string
ModulePath string
StorageType types.Type
Values []EnumColumnValue
}
func (*EnumColumn) MemberForStorage ¶ added in v0.2.2
func (e *EnumColumn) MemberForStorage(value any) (string, bool)
func (*EnumColumn) StorageValue ¶ added in v0.2.2
func (e *EnumColumn) StorageValue(member string) (any, bool)
type EnumColumnValue ¶ added in v0.2.2
type ExplainStyle ¶
type ExplainStyle string
const ( ExplainSQLite ExplainStyle = "sqlite" ExplainText ExplainStyle = "text" ExplainJSON ExplainStyle = "json" )
type ForeignKey ¶
type Introspector ¶
type Manifest ¶
func ManifestFrom ¶
func (*Manifest) EnumColumnsForModule ¶ added in v0.2.2
func (m *Manifest) EnumColumnsForModule(module string) []*EnumColumn
func (*Manifest) ExtensionName ¶
func (*Manifest) ModelsForModule ¶
type Model ¶
type Model struct {
Name string
QueryType string
Table string
ModulePath string
Columns []Column
Associations []Association
UniqueConstraints []UniqueConstraint
}
func (Model) Association ¶
func (m Model) Association(name string) (Association, bool)
func (Model) ChangesType ¶
func (Model) PrimaryKey ¶
type Operator ¶
type Operator string
const ( Equal Operator = "=" NotEqual Operator = "!=" LessThan Operator = "<" LessThanOrEqual Operator = "<=" GreaterThan Operator = ">" GreaterThanOrEqual Operator = ">=" In Operator = "IN" RangeInclusive Operator = "RANGE_INCLUSIVE" RangeExclusive Operator = "RANGE_EXCLUSIVE" NotIn Operator = "NOT_IN" )
type Predicate ¶
type Predicate struct {
Column string
Operator Operator
Value ir.Expression
}
func Predicates ¶
type Schema ¶
func InspectSchema ¶ added in v0.2.1
type Table ¶
type Table struct {
Name string
Columns []Column
ForeignKeys []ForeignKey
UniqueConstraints []UniqueConstraint
}
type UniqueConstraint ¶
Click to show internal directories.
Click to hide internal directories.