Documentation
¶
Index ¶
Constants ¶
View Source
const TagIsRelation = "relation"
TagIsRelation is a tag that indicates that the field is a relation.
Variables ¶
This section is empty.
Functions ¶
func AsModel ¶
func AsModel[Model any](i InternalValue) (Model, error)
AsModel decodes an InternalValue to a model. It uses mapstructure package to do so.
Types ¶
type BaseModel ¶
type BaseModel struct { ID uuid.UUID `gorm:"type:uuid;primary_key;" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
BaseModel contains common columns for all tables.
type InternalValue ¶
InternalValue is a map that holds model data. It is used to avoid heavy use of reflection during read operations.
func AsInternalValue ¶
func AsInternalValue[Model any](entity Model) InternalValue
AsInternalValue Uses reflect package to do a shallow translation of the model to a map wrapped in an InternalValue. We could use mapstructure, but it does a deep translation, which is not what we want.
type SliceField ¶
type SliceField[T any] []T
SliceField is a field that represents a slice of any type
func (*SliceField[T]) FromRepresentation ¶
func (s *SliceField[T]) FromRepresentation(rawValue any) error
func (*SliceField[T]) Scan ¶
func (s *SliceField[T]) Scan(value any) error
Scan scan value into Jsonb, implements sql.Scanner interface
func (SliceField[T]) ToRepresentation ¶
func (s SliceField[T]) ToRepresentation() (any, error)
Click to show internal directories.
Click to hide internal directories.