| 1 |
package clause |
| 2 |
|
| 3 |
// AssociationOpType represents association operation types |
| 4 |
type AssociationOpType int |
| 5 |
|
| 6 |
const ( |
| 7 |
OpUnlink AssociationOpType = iota // Unlink association |
| 8 |
OpDelete // Delete association records |
| 9 |
OpUpdate // Update association records |
| 10 |
OpCreate // Create association records with assignments |
| 11 |
) |
| 12 |
|
| 13 |
// Association represents an association operation |
| 14 |
type Association struct { |
| 15 |
Association string // Association name |
| 16 |
Type AssociationOpType // Operation type |
| 17 |
Conditions []Expression // Filter conditions |
| 18 |
Set []Assignment // Assignment operations (for Update and Create) |
| 19 |
Values []interface{} // Values for Create operation |
| 20 |
} |
| 21 |
|
| 22 |
// AssociationAssigner is an interface for association operation providers |
| 23 |
type AssociationAssigner interface { |
| 24 |
AssociationAssignments() []Association |
| 25 |
} |
| 26 |
|
| 27 |
// Assignments implements the Assigner interface so that AssociationOperation can be used as a Set method parameter |
| 28 |
func (ao Association) Assignments() []Assignment { |
| 29 |
return []Assignment{} |
| 30 |
} |
| 31 |
|
| 32 |
// AssociationAssignments implements the AssociationAssigner interface |
| 33 |
func (ao Association) AssociationAssignments() []Association { |
| 34 |
return []Association{ao} |
| 35 |
} |