database

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 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 NewMySQL

func NewMySQL(dsn string) Database

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