Documentation
¶
Index ¶
- Variables
- func CreateModelConstraints(database *gorm.DB, modelConstraints *ModelConstraints) (err error)
- func CreateModelsConstraints(database *gorm.DB, modelsConstraints []*ModelConstraints) error
- func HasConstraint(database *gorm.DB, model interface{}, name string) bool
- func SetupJoinTable(database *gorm.DB, joinField *JoinField) error
- func SetupJoinTables(database *gorm.DB, joinFields []*JoinField) (err error)
- type JoinField
- type ModelConstraints
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNilJoinField = errors.New("join field cannot be nil") ErrNilModelConstraints = errors.New("model constraints cannot be nil") )
Functions ¶
func CreateModelConstraints ¶
func CreateModelConstraints( database *gorm.DB, modelConstraints *ModelConstraints, ) (err error)
CreateModelConstraints creates model constraints
Parameters:
- database: The GORM database connection
- modelConstraints: The model constraints to create
Returns:
- error: An error if something went wrong, or nil if everything went fine
func CreateModelsConstraints ¶
func CreateModelsConstraints( database *gorm.DB, modelsConstraints []*ModelConstraints, ) error
CreateModelsConstraints creates models constraints
Parameters:
- database: The GORM database connection
- modelsConstraints: The models constraints to create
Returns:
- error: An error if something went wrong, or nil if everything went fine
func HasConstraint ¶
HasConstraint checks if a constraint exists
Parameters:
- database: The GORM database connection
- model: The model to check the constraint
- name: The name of the constraint to check
Returns:
- bool: True if the constraint exists, false otherwise
func SetupJoinTable ¶
SetupJoinTable setups the join table
Parameters:
- database: the gorm database connection
- joinField: the join field
Returns:
- error: if any error occurs
Types ¶
type JoinField ¶
type JoinField struct {
// contains filtered or unexported fields
}
JoinField struct
func NewJoinField ¶
NewJoinField creates a new join field
Parameters:
- model: the model struct
- field: the field name
- joinTable: the join table struct
Returns:
- *JoinField: the join field
type ModelConstraints ¶
type ModelConstraints struct {
// contains filtered or unexported fields
}
ModelConstraints struct
func NewModelConstraints ¶
func NewModelConstraints(model interface{}, names ...string) *ModelConstraints
NewModelConstraints creates a new model constraints
Parameters:
- model: The model to create the constraints for
- names: The names of the constraints to create
Returns:
- *ModelConstraints: The model constraints
Click to show internal directories.
Click to hide internal directories.