store

package
v0.0.0-...-2e66de2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SQLDict map[string]map[string]string

Functions

func GetSQL

func GetSQL(dbType string, queryTag string) string

Types

type DataStore

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

Store is the data structure wrapping the underlying database interactions. It contains the handle to the database, i.e. the database handle representing a pool of zero or more underlying connections.

func GetStore

func GetStore(dbtype string, dbConn *sql.DB, redisClient *redis.Client, redisTTL int) (*DataStore, error)

GetStore is the constructor for the Store struct and does the actual work of creating the DB handler.

func NewStore

func NewStore(dbtype string, dbConn *sql.DB, redisClient *redis.Client, redisTTL int) (*DataStore, error)

func (*DataStore) Add

func (s *DataStore) Add(r routes.Route) (int, error)

func (*DataStore) Delete

func (s *DataStore) Delete(k string) error

func (*DataStore) DumpAllRoutes

func (s *DataStore) DumpAllRoutes() ([]routes.Route, error)

func (*DataStore) Get

func (s *DataStore) Get(k string) (routes.Route, error)

Get is

func (*DataStore) GetAllUsers

func (s *DataStore) GetAllUsers() error

func (*DataStore) GetRandomURL

func (s *DataStore) GetRandomURL(k string) (routes.Route, error)

func (*DataStore) GetURL

func (s *DataStore) GetURL(k string) (string, error)

GetURL is the main entry point for the app. It is the shortlink. The other getters are designed for potentially slower access via an editor tool.

func (*DataStore) GetUser

func (s *DataStore) GetUser(username string) (*User, error)

func (*DataStore) IsSQLErrDuplicateContraint

func (s *DataStore) IsSQLErrDuplicateContraint(err error) bool

func (*DataStore) IsSQLErrUniqueContraint

func (s *DataStore) IsSQLErrUniqueContraint(err error) bool

func (*DataStore) Lock

func (s *DataStore) Lock(r routes.Route) (int, error)

Lock locks the entry so that it requires admin to unlock and change

func (*DataStore) MakeAdmin

func (s *DataStore) MakeAdmin(username string, admin string) (int, error)

func (*DataStore) Modify

func (s *DataStore) Modify(r routes.Route) (int, error)

type RouteStore

type RouteStore interface {
	Add(routes.Route) (int, error)
	Modify(routes.Route) (int, error)
	Get(string) routes.Route
	Delete(string) bool
	GetUserID(username string) (int, error)
	GetURL(string) (string, error)
	Lock(routes.Route) (bool, error)
}

type User

type User struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	IsAdmin int    `json:"isadmin,omitempty"`
}

Jump to

Keyboard shortcuts

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