dbx

package
v0.0.0-...-48595db Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID     int64     `db:"id" json:"id"`
	Status int       `db:"status" json:"-"`
	Ctime  time.Time `db:"ctime" json:"ctime"`
	Mtime  time.Time `db:"mtime" json:"-"`
}

BaseModel base model

type Q

type Q[T any, ID any] struct {
	TableName string
	// contains filtered or unexported fields
}

func NewQ

func NewQ[T any, ID any](db db.Session, table string) *Q[T, ID]

func (*Q[T, ID]) DeleteBy

func (q *Q[T, ID]) DeleteBy(cond db.Cond) error

func (*Q[T, ID]) Get

func (q *Q[T, ID]) Get(id ID) (*T, error)

Get get a record by id

func (*Q[T, ID]) GetBy

func (q *Q[T, ID]) GetBy(field string, value any) (*T, error)

func (*Q[T, ID]) GetMulti

func (q *Q[T, ID]) GetMulti(ids []ID) (ts []T, err error)

func (*Q[T, ID]) LikeBy

func (q *Q[T, ID]) LikeBy(prefix string) ([]T, error)

func (*Q[T, ID]) ListBy

func (q *Q[T, ID]) ListBy(cond db.Cond, order string, offset, limit int) ([]*T, error)

func (*Q[T, ID]) Save

func (q *Q[T, ID]) Save(t db.Record) error

Save save a record

Jump to

Keyboard shortcuts

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