gormq

package
v0.0.0-...-0a075e9 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 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 Query

type Query struct {
	SelectFields []string
	Conditions   []func(db *gorm.DB) *gorm.DB
	Preloads     []func(db *gorm.DB) *gorm.DB
	Order        func(db *gorm.DB) *gorm.DB
	Limit        func(db *gorm.DB) *gorm.DB
	ForUpdate    func(db *gorm.DB) *gorm.DB
}

func NewQuery

func NewQuery(f []string) *Query

func (*Query) AddOr

func (a *Query) AddOr(cond string, v interface{})

func (*Query) AddPreload

func (a *Query) AddPreload(target string)

func (*Query) AddWhere

func (a *Query) AddWhere(cond string, v interface{})

func (*Query) EnableForUpdate

func (a *Query) EnableForUpdate()

func (*Query) SetLimit

func (a *Query) SetLimit(v int)

func (*Query) SetOrder

func (a *Query) SetOrder(cond string)

type Repo

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

func (*Repo) GetUser

func (a *Repo) GetUser(q *Query) (User, error)

func (*Repo) GetUsers

func (a *Repo) GetUsers(q *Query) ([]User, error)

type User

type User struct {
	ID        uint      `json:"-" gorm:"primary_key"`
	CreatedAt time.Time `json:"createdAt" gorm:"index"`
	UpdatedAt time.Time `json:"updatedAt" gorm:"index"`
	Email     string    `json:"email" gorm:"unique_index"`
	Name      string    `json:"name" gorm:"name"`
}

Jump to

Keyboard shortcuts

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