db

package
v1.1.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Disconnect added in v1.0.5

func Disconnect() error

Disconnect disconnect

func DoTransaction

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

DoTransaction do transaction

func InitDB added in v1.0.5

func InitDB()

InitDB init db

func InitRedis added in v1.0.5

func InitRedis()

InitRedis init Redis

func RedisDecr added in v1.0.2

func RedisDecr(key string) (int64, error)

RedisDecr redis decrease

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 RedisGetInt added in v1.0.2

func RedisGetInt(key string) (int64, error)

RedisGetInt get int64

func RedisGetString added in v1.0.2

func RedisGetString(key string) (string, error)

RedisGetString get string

func RedisIncr added in v1.0.2

func RedisIncr(key string) (int64, error)

RedisIncr redis increase

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

func RedisSetString added in v1.0.2

func RedisSetString(key string, val string, expire time.Duration) error

RedisSetString set string

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;unique"`
	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