database

package
v2.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BboltDB

type BboltDB struct {
}

BboltDB implement Database interface with ETCD's bbolt

func (*BboltDB) Close

func (d *BboltDB) Close() error

Close close the db file

func (*BboltDB) CountAll

func (d *BboltDB) CountAll() (int, error)

CountAll Fetch records count

func (*BboltDB) DeviceTokenByKey

func (d *BboltDB) DeviceTokenByKey(key string) (string, error)

DeviceTokenByKey get device token of specified key

func (*BboltDB) SaveDeviceTokenByKey

func (d *BboltDB) SaveDeviceTokenByKey(key, deviceToken string) (string, error)

SaveDeviceToken create or update device token of specified key

type Database

type Database interface {
	CountAll() (int, error)                                 //Get db records count
	DeviceTokenByKey(key string) (string, error)            //Get specified device's token
	SaveDeviceTokenByKey(key, token string) (string, error) //Create or update specified devices's token
	Close() error                                           //Close the database
}

Database defines all of the db operation

func NewBboltdb

func NewBboltdb(dataDir string) Database

func NewEnvBase added in v2.1.0

func NewEnvBase() Database

func NewMySQL

func NewMySQL(dsn string) Database

type EnvBase added in v2.1.0

type EnvBase struct {
}

func (*EnvBase) Close added in v2.1.0

func (d *EnvBase) Close() error

func (*EnvBase) CountAll added in v2.1.0

func (d *EnvBase) CountAll() (int, error)

func (*EnvBase) DeviceTokenByKey added in v2.1.0

func (d *EnvBase) DeviceTokenByKey(key string) (string, error)

func (*EnvBase) SaveDeviceTokenByKey added in v2.1.0

func (d *EnvBase) SaveDeviceTokenByKey(key, token string) (string, error)

type MySQL

type MySQL struct {
}

func (*MySQL) Close

func (d *MySQL) Close() error

func (*MySQL) CountAll

func (d *MySQL) CountAll() (int, error)

func (*MySQL) DeviceTokenByKey

func (d *MySQL) DeviceTokenByKey(key string) (string, error)

func (*MySQL) SaveDeviceTokenByKey

func (d *MySQL) SaveDeviceTokenByKey(key, token string) (string, error)

Jump to

Keyboard shortcuts

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