model

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delete

type Delete[T any] struct {
	// contains filtered or unexported fields
}

func (*Delete[T]) Where

func (d *Delete[T]) Where(query any, args ...any) *DeleteWheres[T]

type DeleteWheres

type DeleteWheres[T any] struct {
	// contains filtered or unexported fields
}

func NewDeleteWheres

func NewDeleteWheres[T any](tx *gorm.DB, entry T) *DeleteWheres[T]

func (*DeleteWheres[T]) Delete

func (w *DeleteWheres[T]) Delete() error

func (*DeleteWheres[T]) Where

func (w *DeleteWheres[T]) Where(query interface{}, args ...interface{}) *DeleteWheres[T]

type EntryModel

type EntryModel[T IEntry] struct {
	// contains filtered or unexported fields
}

func NewEntryModel

func NewEntryModel[T IEntry](db *gorm.DB, tableName string) *EntryModel[T]

func (*EntryModel[T]) CreateTable

func (a *EntryModel[T]) CreateTable() error

func (*EntryModel[T]) Delete

func (a *EntryModel[T]) Delete() *Delete[T]

func (*EntryModel[T]) DeleteOne

func (a *EntryModel[T]) DeleteOne(id uint) error

func (*EntryModel[T]) DeleteTable

func (a *EntryModel[T]) DeleteTable() error

func (*EntryModel[T]) FindAll

func (a *EntryModel[T]) FindAll() ([]T, error)

func (*EntryModel[T]) FindAllByIds

func (a *EntryModel[T]) FindAllByIds(id ...uint) ([]T, error)

func (*EntryModel[T]) FindById

func (a *EntryModel[T]) FindById(id uint) (T, error)

func (*EntryModel[T]) FindOne

func (a *EntryModel[T]) FindOne(query interface{}, args ...interface{}) (T, error)

func (*EntryModel[T]) GetTableName

func (a *EntryModel[T]) GetTableName() string

func (*EntryModel[T]) IsExist

func (a *EntryModel[T]) IsExist() bool

func (*EntryModel[T]) NewEntryModel

func (a *EntryModel[T]) NewEntryModel(db *gorm.DB) *EntryModel[T]

func (*EntryModel[T]) Page

func (a *EntryModel[T]) Page(page *web.Page) ([]T, int, error)

func (*EntryModel[T]) Query

func (a *EntryModel[T]) Query() *Query[T]

func (*EntryModel[T]) QueryPage

func (a *EntryModel[T]) QueryPage(page *web.Page, query interface{}, args ...interface{}) ([]T, int, error)

func (*EntryModel[T]) Save

func (a *EntryModel[T]) Save(t T) error

func (*EntryModel[T]) Saves

func (a *EntryModel[T]) Saves(ts []T) error

func (*EntryModel[T]) Update

func (a *EntryModel[T]) Update() *Update[T]

func (*EntryModel[T]) UpdateById

func (a *EntryModel[T]) UpdateById(t T) error

func (*EntryModel[T]) UpdateColumn

func (a *EntryModel[T]) UpdateColumn(id uint, column string, value interface{}) error

func (*EntryModel[T]) UpdateForMap

func (a *EntryModel[T]) UpdateForMap(id uint, data map[string]interface{}) error

type IEntry

type IEntry interface {
	SetCreateTime(createTime time.Time)
	SetUpdateTime(updateTIme time.Time)
	GetId() uint
	SetId(id uint)
}

type Model

type Model[T any] struct {
	// contains filtered or unexported fields
}

func NewModel

func NewModel[T any](db *gorm.DB, tableName string) *Model[T]

func (*Model[T]) CreateTable

func (a *Model[T]) CreateTable() error

func (*Model[T]) Delete

func (a *Model[T]) Delete() *Delete[T]

func (*Model[T]) DeleteTable

func (a *Model[T]) DeleteTable() error

func (*Model[T]) GetTableName

func (a *Model[T]) GetTableName() string

func (*Model[T]) IsExist

func (a *Model[T]) IsExist() bool

func (*Model[T]) Query

func (a *Model[T]) Query() *Query[T]

func (*Model[T]) Save

func (a *Model[T]) Save(entry T) error

func (*Model[T]) Saves

func (a *Model[T]) Saves(entry []T) error

func (*Model[T]) Update

func (a *Model[T]) Update() *Update[T]

type Page

type Page[T any] struct {
	Total int `json:"total"`
	List  []T `json:"list"`
}

func ToPage

func ToPage[T IEntry](total int, list []T) *Page[T]

type Query

type Query[T any] struct {
	// contains filtered or unexported fields
}

func (*Query[T]) All

func (q *Query[T]) All() ([]T, error)

func (*Query[T]) List

func (q *Query[T]) List(size int) ([]T, error)

func (*Query[T]) ListPage

func (q *Query[T]) ListPage(page *web.Page) ([]T, error)

func (*Query[T]) One

func (q *Query[T]) One() (T, error)

func (*Query[T]) Order

func (q *Query[T]) Order(query interface{}) *Query[T]

func (*Query[T]) Page

func (q *Query[T]) Page(page *web.Page) ([]T, int, error)

func (*Query[T]) Size

func (q *Query[T]) Size(size int) ([]T, int, error)

func (*Query[T]) Where

func (q *Query[T]) Where(query interface{}, args ...interface{}) *Query[T]

type Transaction

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

func NewTransaction

func NewTransaction(db *gorm.DB) *Transaction

func (*Transaction) Exec

func (t *Transaction) Exec(fc func(tx *gorm.DB) error) error

type Update

type Update[T any] struct {
	// contains filtered or unexported fields
}

func (*Update[T]) Where

func (u *Update[T]) Where(query any, args ...any) *UpdateWheres[T]

type UpdateWheres

type UpdateWheres[T any] struct {
	// contains filtered or unexported fields
}

func NewUpdateWheres

func NewUpdateWheres[T any](tx *gorm.DB) *UpdateWheres[T]

func (*UpdateWheres[T]) Update

func (w *UpdateWheres[T]) Update(t T) error

func (*UpdateWheres[T]) UpdateColumn

func (w *UpdateWheres[T]) UpdateColumn(column string, value any) error

func (*UpdateWheres[T]) UpdateForMap

func (w *UpdateWheres[T]) UpdateForMap(mapValue map[string]any) error

func (*UpdateWheres[T]) Where

func (w *UpdateWheres[T]) Where(query interface{}, args ...interface{}) *UpdateWheres[T]

Jump to

Keyboard shortcuts

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