utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendAssociations

func AppendAssociations(db *gorm.DB, item interface{}) error

AppendAssociations uses reflection to find all exported slice fields in 'item' and then appends any elements in each slice to the association.

func FindPhraseByStringFields

func FindPhraseByStringFields[T any](phrase string, entity T) ([]*T, error)

func GetColumnName

func GetColumnName(model any, fieldName string, db *gorm.DB) (string, error)

func GetTableName

func GetTableName(model any, db *gorm.DB) (string, error)

func ReplaceEmptySlicesWithNil

func ReplaceEmptySlicesWithNil(v interface{})

ReplaceEmptySlicesWithNil takes a pointer to any struct (or struct-like type) and replaces all empty slices with nil, traversing nested fields recursively.

func SortByOrder

func SortByOrder[T any](fieldsSortingOrder []SortField, entity T) ([]*T, error)

func UpdateAssociations

func UpdateAssociations(db *gorm.DB, item interface{}) error

Types

type SortField

type SortField struct {
	Name  string
	Order string
}

Jump to

Keyboard shortcuts

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