2021-08-25 15:34:33 +02:00
|
|
|
package schema
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
InvalidRelation = iota
|
|
|
|
HasOneRelation
|
|
|
|
BelongsToRelation
|
|
|
|
HasManyRelation
|
|
|
|
ManyToManyRelation
|
|
|
|
)
|
|
|
|
|
|
|
|
type Relation struct {
|
|
|
|
Type int
|
|
|
|
Field *Field
|
|
|
|
JoinTable *Table
|
|
|
|
BaseFields []*Field
|
|
|
|
JoinFields []*Field
|
2022-08-15 12:35:05 +02:00
|
|
|
OnUpdate string
|
|
|
|
OnDelete string
|
|
|
|
Condition []string
|
2021-08-25 15:34:33 +02:00
|
|
|
|
|
|
|
PolymorphicField *Field
|
|
|
|
PolymorphicValue string
|
|
|
|
|
|
|
|
M2MTable *Table
|
|
|
|
M2MBaseFields []*Field
|
|
|
|
M2MJoinFields []*Field
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Relation) String() string {
|
|
|
|
return fmt.Sprintf("relation=%s", r.Field.GoName)
|
|
|
|
}
|