2021-08-25 13:34:33 +00: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 10:35:05 +00:00
|
|
|
OnUpdate string
|
|
|
|
OnDelete string
|
|
|
|
Condition []string
|
2021-08-25 13:34:33 +00:00
|
|
|
|
|
|
|
PolymorphicField *Field
|
|
|
|
PolymorphicValue string
|
|
|
|
|
|
|
|
M2MTable *Table
|
|
|
|
M2MBaseFields []*Field
|
|
|
|
M2MJoinFields []*Field
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *Relation) String() string {
|
|
|
|
return fmt.Sprintf("relation=%s", r.Field.GoName)
|
|
|
|
}
|