demo

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 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 OrmUsers

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

func NewOrmUsers

func NewOrmUsers() *OrmUsers

func (*OrmUsers) And

func (orm *OrmUsers) And(fuc func(orm *OrmUsers)) *OrmUsers

func (*OrmUsers) Begin

func (orm *OrmUsers) Begin(opts ...*sql.TxOptions) *gorm.DB

Begin begins a transaction

func (*OrmUsers) Commit

func (orm *OrmUsers) Commit() *gorm.DB

Commit commit a transaction

func (*OrmUsers) Connection

func (orm *OrmUsers) Connection(fc func(tx *gorm.DB) error) (err error)

Connection use a db conn to execute Multiple commands,this conn will put conn pool after it is executed.

func (*OrmUsers) Count

func (orm *OrmUsers) Count() int64

func (*OrmUsers) Create

func (orm *OrmUsers) Create(value interface{}) *gorm.DB

Create insert the value into database

func (*OrmUsers) CreateInBatches

func (orm *OrmUsers) CreateInBatches(value interface{}, batchSize int) *gorm.DB

CreateInBatches insert the value in batches into database

func (*OrmUsers) Delete

func (orm *OrmUsers) Delete(conds ...interface{}) *gorm.DB

Delete 有条件删除

func (*OrmUsers) DeleteAll

func (orm *OrmUsers) DeleteAll() *gorm.DB

DeleteAll 删除所有

func (*OrmUsers) Exec

func (orm *OrmUsers) Exec(sql string, values ...interface{}) *gorm.DB

Exec execute raw sql

func (*OrmUsers) Find

func (orm *OrmUsers) Find(conds ...interface{}) (UsersList, int64)

func (*OrmUsers) FindInBatches

func (orm *OrmUsers) FindInBatches(dest interface{}, batchSize int, fc func(tx *gorm.DB, batch int) error) *gorm.DB

FindInBatches find records in batches

func (*OrmUsers) First

func (orm *OrmUsers) First(conds ...interface{}) (*Users, bool)

First 检索单个对象

func (*OrmUsers) FirstOrCreate

func (orm *OrmUsers) FirstOrCreate(dest interface{}, conds ...interface{}) *gorm.DB

FirstOrCreate gets the first matched record or create a new one with given conditions (only works with struct, map conditions)

func (*OrmUsers) FirstOrInit

func (orm *OrmUsers) FirstOrInit(dest *Users, conds ...interface{}) (*Users, *gorm.DB)

FirstOrInit gets the first matched record or initialize a new instance with given conditions (only works with struct or map conditions)

func (*OrmUsers) Get

func (orm *OrmUsers) Get() UsersList

直接查询列表, 如果需要条数, 使用Find()

func (*OrmUsers) GetDB

func (orm *OrmUsers) GetDB() *gorm.DB

func (*OrmUsers) Insert

func (orm *OrmUsers) Insert(row *Users) *gorm.DB

func (*OrmUsers) InsertGetEmail

func (orm *OrmUsers) InsertGetEmail(row *Users) string

func (*OrmUsers) InsertGetId

func (orm *OrmUsers) InsertGetId(row *Users) int64

func (*OrmUsers) Inserts

func (orm *OrmUsers) Inserts(rows []*Users) *gorm.DB

func (*OrmUsers) Last

func (orm *OrmUsers) Last(conds ...interface{}) (*Users, int64)

Last find last record that match given conditions, order by primary key

func (*OrmUsers) Limit

func (orm *OrmUsers) Limit(limit int) *OrmUsers

func (*OrmUsers) Offset

func (orm *OrmUsers) Offset(offset int) *OrmUsers

func (*OrmUsers) Or

func (orm *OrmUsers) Or(fuc func(orm *OrmUsers)) *OrmUsers

func (*OrmUsers) Order

func (orm *OrmUsers) Order(value interface{}) *OrmUsers

func (*OrmUsers) Pluck

func (orm *OrmUsers) Pluck(column string, dest interface{}) *gorm.DB

Pluck used to query single column from a model as a map

var ages []int64
db.Model(&users).Pluck("age", &ages)

func (*OrmUsers) Rollback

func (orm *OrmUsers) Rollback() *gorm.DB

Rollback rollback a transaction

func (*OrmUsers) RollbackTo

func (orm *OrmUsers) RollbackTo(name string) *gorm.DB

func (*OrmUsers) Row

func (orm *OrmUsers) Row() *sql.Row

func (*OrmUsers) Rows

func (orm *OrmUsers) Rows() (*sql.Rows, error)

func (*OrmUsers) Save

func (orm *OrmUsers) Save(value interface{}) *gorm.DB

Save update value in database, if the value doesn't have primary key, will insert it

func (*OrmUsers) SavePoint

func (orm *OrmUsers) SavePoint(name string) *gorm.DB

func (*OrmUsers) Scan

func (orm *OrmUsers) Scan(dest interface{}) *gorm.DB

Scan scan value to a struct

func (*OrmUsers) ScanRows

func (orm *OrmUsers) ScanRows(rows *sql.Rows, dest interface{}) error

func (*OrmUsers) Take

func (orm *OrmUsers) Take(conds ...interface{}) (*Users, int64)

Take return a record that match given conditions, the order will depend on the database implementation

func (*OrmUsers) Transaction

func (orm *OrmUsers) Transaction(fc func(tx *gorm.DB) error, opts ...*sql.TxOptions) (err error)

Transaction start a transaction as a block, return error will rollback, otherwise to commit.

func (*OrmUsers) Update

func (orm *OrmUsers) Update(column string, value interface{}) *gorm.DB

Update update attributes with callbacks, refer: https://gorm.io/docs/update.html#Update-Changed-Fields

func (*OrmUsers) UpdateColumn

func (orm *OrmUsers) UpdateColumn(column string, value interface{}) *gorm.DB

func (*OrmUsers) UpdateColumns

func (orm *OrmUsers) UpdateColumns(values interface{}) *gorm.DB

func (*OrmUsers) Updates

func (orm *OrmUsers) Updates(values interface{}) *gorm.DB

Updates update attributes with callbacks, refer: https://gorm.io/docs/update.html#Update-Changed-Fields

func (*OrmUsers) Where

func (orm *OrmUsers) Where(query interface{}, args ...interface{}) *OrmUsers

func (*OrmUsers) WhereCreatedAt

func (orm *OrmUsers) WhereCreatedAt(val database.Time) *OrmUsers

func (*OrmUsers) WhereCreatedAtBetween

func (orm *OrmUsers) WhereCreatedAtBetween(begin database.Time, end database.Time) *OrmUsers

func (*OrmUsers) WhereCreatedAtGte

func (orm *OrmUsers) WhereCreatedAtGte(val database.Time) *OrmUsers

func (*OrmUsers) WhereCreatedAtLte

func (orm *OrmUsers) WhereCreatedAtLte(val database.Time) *OrmUsers

func (*OrmUsers) WhereEmail

func (orm *OrmUsers) WhereEmail(val string) *OrmUsers

func (*OrmUsers) WhereEmailGt

func (orm *OrmUsers) WhereEmailGt(val string) *OrmUsers

func (*OrmUsers) WhereEmailGte

func (orm *OrmUsers) WhereEmailGte(val string) *OrmUsers

func (*OrmUsers) WhereEmailIn

func (orm *OrmUsers) WhereEmailIn(val []string) *OrmUsers

func (*OrmUsers) WhereEmailLt

func (orm *OrmUsers) WhereEmailLt(val string) *OrmUsers

func (*OrmUsers) WhereEmailLte

func (orm *OrmUsers) WhereEmailLte(val string) *OrmUsers

func (*OrmUsers) WhereEmailVerifiedAt

func (orm *OrmUsers) WhereEmailVerifiedAt(val database.Time) *OrmUsers

func (*OrmUsers) WhereEmailVerifiedAtBetween

func (orm *OrmUsers) WhereEmailVerifiedAtBetween(begin database.Time, end database.Time) *OrmUsers

func (*OrmUsers) WhereEmailVerifiedAtGte

func (orm *OrmUsers) WhereEmailVerifiedAtGte(val database.Time) *OrmUsers

func (*OrmUsers) WhereEmailVerifiedAtLte

func (orm *OrmUsers) WhereEmailVerifiedAtLte(val database.Time) *OrmUsers

func (*OrmUsers) WhereId

func (orm *OrmUsers) WhereId(val int64) *OrmUsers

func (*OrmUsers) WhereIdGt

func (orm *OrmUsers) WhereIdGt(val int64) *OrmUsers

func (*OrmUsers) WhereIdGte

func (orm *OrmUsers) WhereIdGte(val int64) *OrmUsers

func (*OrmUsers) WhereIdIn

func (orm *OrmUsers) WhereIdIn(val []int64) *OrmUsers

func (*OrmUsers) WhereIdLt

func (orm *OrmUsers) WhereIdLt(val int64) *OrmUsers

func (*OrmUsers) WhereIdLte

func (orm *OrmUsers) WhereIdLte(val int64) *OrmUsers

func (*OrmUsers) WhereName

func (orm *OrmUsers) WhereName(val string) *OrmUsers

func (*OrmUsers) WherePassword

func (orm *OrmUsers) WherePassword(val string) *OrmUsers

func (*OrmUsers) WhereRememberToken

func (orm *OrmUsers) WhereRememberToken(val string) *OrmUsers

func (*OrmUsers) WhereUpdatedAt

func (orm *OrmUsers) WhereUpdatedAt(val database.Time) *OrmUsers

func (*OrmUsers) WhereUpdatedAtBetween

func (orm *OrmUsers) WhereUpdatedAtBetween(begin database.Time, end database.Time) *OrmUsers

func (*OrmUsers) WhereUpdatedAtGte

func (orm *OrmUsers) WhereUpdatedAtGte(val database.Time) *OrmUsers

func (*OrmUsers) WhereUpdatedAtLte

func (orm *OrmUsers) WhereUpdatedAtLte(val database.Time) *OrmUsers

type Users

type Users struct {
	Id              int64          `gorm:"column:id;autoIncrement;type:bigint(20) unsigned;primaryKey"`               //
	Name            string         `gorm:"column:name;type:varchar(255)"`                                             //
	Email           string         `gorm:"column:email;type:varchar(255);index:users_email_unique,class:HASH,unique"` //
	EmailVerifiedAt *database.Time `gorm:"column:email_verified_at;type:timestamp;default:NULL"`                      //
	Password        string         `gorm:"column:password;type:varchar(255)"`                                         //
	RememberToken   *string        `gorm:"column:remember_token;type:varchar(100);default:NULL"`                      //
	CreatedAt       *database.Time `gorm:"column:created_at;type:timestamp;default:NULL"`                             //
	UpdatedAt       *database.Time `gorm:"column:updated_at;type:timestamp;default:NULL"`                             //
}

func (*Users) TableName

func (receiver *Users) TableName() string

type UsersList

type UsersList []*Users

func (UsersList) GetIdList

func (l UsersList) GetIdList() []int64

func (UsersList) GetIdMap

func (l UsersList) GetIdMap() map[int64]*Users

Jump to

Keyboard shortcuts

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