store

package
v0.0.0-...-840a1b4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2017 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

View Source
const Key = "store"

Key is the key name of the store in the Gin context.

Variables

This section is empty.

Functions

func CreateUser

func CreateUser(c *gin.Context, user *model.User) error

CreateUser creates a new user account.

func DeleteUser

func DeleteUser(c *gin.Context, id int) error

DeleteUser deletes the user by the user identifier.

func GetLastUser

func GetLastUser(c *gin.Context) (*model.User, error)

GetLastUser gets the last user.

func GetUser

func GetUser(c *gin.Context, username string) (*model.User, error)

GetUser gets an user by the user identifier.

func GetUserAfter

func GetUserAfter(c *gin.Context, id int) (*model.User, error)

GetUserAfter gets the user who is registered after the specified user.

func ToContext

func ToContext(c Setter, store Store)

ToContext adds the Store to this context if it supports the Setter interface.

func UpdateUser

func UpdateUser(c *gin.Context, user *model.User) error

UpdateUser updates an user account information.

Types

type Setter

type Setter interface {
	Set(string, interface{})
}

Setter defines a context that enables setting values.

type Store

type Store interface {
	CreateUser(*model.User) error
	GetUser(string) (*model.User, error)
	GetLastUser() (*model.User, error)
	GetUserAfter(int) (*model.User, error)
	DeleteUser(int) error
	UpdateUser(*model.User) error
}

Store wraps the functions that interactive with the database, just like the Model in MVC architecture.

func FromContext

func FromContext(c context.Context) Store

FromContext returns the Store associated with this context.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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