models

package
v0.0.0-...-2327e9c Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Copyright © 2023 Codoworks Author: Dexter Codo Contact: dexter.codo@gmail.com

Copyright © 2023 Codoworks Author: Dexter Codo Contact: dexter.codo@gmail.com

Copyright © 2023 Codoworks Author: Dexter Codo Contact: dexter.codo@gmail.com

Copyright © 2023 Codoworks Author: Dexter Codo Contact: dexter.codo@gmail.com

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 Cat

type Cat struct {
	ModelBase
	Name string `gorm:"size:255"`
	Type string `gorm:"size:255"`
}

func CatModel

func CatModel() *Cat

func (*Cat) Delete

func (model *Cat) Delete(id string) error

func (*Cat) Find

func (model *Cat) Find(id string) (m *Cat, err error)

func (*Cat) FindAll

func (model *Cat) FindAll() (models []*Cat, err error)

func (*Cat) FindMany

func (model *Cat) FindMany(ids []string) (models []*Cat, err error)

func (*Cat) MapToForm

func (model *Cat) MapToForm() *CatForm

func (*Cat) Save

func (model *Cat) Save() error

func (*Cat) Update

func (model *Cat) Update() error

type CatForm

type CatForm struct {
	FormBase
	Name string `json:"name" validate:"required,min=2,max=50"`
	Type string `json:"type" validate:"required,min=2,max=80"`
}

func (*CatForm) MapToModel

func (form *CatForm) MapToModel() *Cat

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

Jump to

Keyboard shortcuts

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