models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(database *gorm.DB)

func Paginate

func Paginate(page int, pageSize int) func(db *gorm.DB) *gorm.DB

Types

type FormBase

type FormBase struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ModelBase

type ModelBase struct {
	ID        string `gorm:"type:char(36);primary_key;"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (*ModelBase) BeforeCreate

func (base *ModelBase) BeforeCreate(db *gorm.DB) error

type Test

type Test struct {
	ModelBase
	Name string `gorm:"size:255;not null"` // Test name
}

Satellite Model

func (*Test) MapToForm

func (model *Test) MapToForm() *TestForm

MapToForm maps the Test model to a TestForm.

type TestForm

type TestForm struct {
	FormBase
	Name string `json:"name" validate:"required,min=2,max=255"` // Satellite name
}

func (*TestForm) MapToModel

func (form *TestForm) MapToModel() *Test

Jump to

Keyboard shortcuts

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