db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoTransaction

func DoTransaction(fc func(tx *gorm.DB) error) error

DoTransaction do transaction

func RedisDelete

func RedisDelete(key string) error

RedisDelete delete key

func RedisExist

func RedisExist(key string) bool

RedisExist check key exists

func RedisGet

func RedisGet(key string, out interface{}) error

RedisGet get value

func RedisSet

func RedisSet(key string, val interface{}, expire time.Duration) error

RedisSet set value

func RedisSetBytes

func RedisSetBytes(key string, val interface{}, expire time.Duration) error

RedisSetBytes set bytes

Types

type Application

type Application struct {
	gorm.Model
	Name  string `gorm:"unique;unique_index"`
	Usage uint64 `gorm:"not null;default:0"`
	Liked uint64 `gorm:"not null;default:0"`
}

Application list of applications

func (*Application) Find

func (a *Application) Find() error

Find populate current object

func (*Application) FindWithTx

func (a *Application) FindWithTx(tx *gorm.DB) error

FindWithTx populate current object with transaction

func (*Application) Save

func (a *Application) Save() error

Save save application

func (*Application) SaveWithTx

func (a *Application) SaveWithTx(tx *gorm.DB) error

SaveWithTx save application with transaction

type User

type User struct {
	gorm.Model
	Username  string `gorm:"unique_index"`
	Password  string
	Email     string `gorm:"primary_key"`
	GoogleID  string
	LikedApps pq.StringArray `gorm:"type:text[]"`
}

User database entity

func (*User) Find

func (u *User) Find() error

Find populate current object

func (*User) FindWithTx

func (u *User) FindWithTx(tx *gorm.DB) error

FindWithTx populate current object with transaction

func (*User) Save

func (u *User) Save() error

Save save current user

func (*User) SaveWithTx

func (u *User) SaveWithTx(tx *gorm.DB) error

SaveWithTx save current user with transaction

Jump to

Keyboard shortcuts

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