gorm

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2025 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

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,
) 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

func HasConstraint(database *gorm.DB, model any, name string) bool

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

func SetupJoinTable(
	database *gorm.DB,
	joinField *JoinField,
) error

SetupJoinTable setups the join table

Parameters:

  • database: the gorm database connection
  • joinField: the join field

Returns:

  • error: if any error occurs

func SetupJoinTables

func SetupJoinTables(
	database *gorm.DB,
	joinFields []*JoinField,
) error

SetupJoinTables setups the join tables

Parameters:

  • database: the gorm database connection
  • joinFields: the join fields

Returns:

  • error: if any error occurs

Types

type JoinField

type JoinField struct {
	// contains filtered or unexported fields
}

JoinField struct

func NewJoinField

func NewJoinField(
	model any,
	field string,
	joinTable any,
) *JoinField

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 any, 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL