store

package
v0.0.0-...-3a0a0a1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	//ErrExists indicates you are trying to add an item in the db that already exists
	ErrExists = errors.New("product already exists")
)
View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func AddCategory

func AddCategory(name, p, w string) error

func AddSubcategory

func AddSubcategory(cat, name string) error

func Buckets

func Buckets(buckets ...string) func(*Query)

func DeleteCategory

func DeleteCategory(cat string) error

func DeleteSubcategory

func DeleteSubcategory(cat, subcat string) error

func GetBackup

func GetBackup(w http.ResponseWriter) error

func GetBlogImage

func GetBlogImage(key string) ([]byte, error)

func GetCategories

func GetCategories() ([]string, error)

func GetImage

func GetImage(bucket, title, size string) ([]byte, error)

func GetProductTitles

func GetProductTitles(cat, subcat string) ([]string, error)

func GetSubCategories

func GetSubCategories(cat string) ([]string, error)

func Init

func Init(c config.Config, opts ...func())

func Key

func Key(k string) func(*Query)

func ProductDescription

func ProductDescription(d string) func(*Product)

func ProductImage

func ProductImage(r io.Reader) func(*Product)

func ProductPrice

func ProductPrice(price string) func(*Product)

func RenameCategory

func RenameCategory(old, name string) error

func RenameSubcategory

func RenameSubcategory(cat, old, name string) error

func SavePasswordReset

func SavePasswordReset(email string) (string, error)

func SetDB

func SetDB(d storer) func()

func SetPrice

func SetPrice(name string, price Price) error

func Val

func Val(v []byte) func(*Query)

Types

type Address

type Address struct {
	Address  string `schema:"address" json:"address,omitempty"`
	Address2 string `schema:"address2" json:"address2,omitempty"`
	Zip      string `schema:"zip" json:"zip,omitempty"`
	City     string `schema:"city" json:"city,omitempty"`
	State    string `schema:"state" json:"state,omitempty"`
	Country  string `schema:"country" json:"country,omitempty"`
}

type Blog

type Blog struct {
	Title string    `json:"title" schema:"title"`
	Date  time.Time `json:"date" schema:"date"`
	Body  string    `json:"body" schema:"body"`
	// contains filtered or unexported fields
}

func CurrentBlog

func CurrentBlog() (Blog, error)

func GetBlog

func GetBlog(key string) (Blog, error)

func (*Blog) Delete

func (b *Blog) Delete() error

func (*Blog) Fetch

func (b *Blog) Fetch() error

func (*Blog) Key

func (b *Blog) Key() string

func (*Blog) Save

func (b *Blog) Save(img io.Reader) error

func (*Blog) Update

func (b *Blog) Update(b2 Blog, img io.Reader) error

type BlogKey

type BlogKey struct {
	Date  string
	Title string
	ID    string
}

func Blogs

func Blogs() ([]BlogKey, error)

type Bolt

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

func (*Bolt) AddBucket

func (b *Bolt) AddBucket(row Query) error

func (*Bolt) Delete

func (b *Bolt) Delete(rows []Query) error

func (*Bolt) DeleteAll

func (b *Bolt) DeleteAll(bucket []byte) error

func (*Bolt) Get

func (b *Bolt) Get(rows []Query, f func(key, val []byte) error) error

func (*Bolt) GetAll

func (b *Bolt) GetAll(r Query, f func(key, val []byte) error) error

func (*Bolt) GetBackup

func (b *Bolt) GetBackup(w http.ResponseWriter) error

func (*Bolt) Put

func (b *Bolt) Put(rows []Query) error

func (*Bolt) RenameBucket

func (b *Bolt) RenameBucket(src, dst Query) error

Rename bucket takes 2 rows, the first should point to

type Permission

type Permission int
const (
	Read Permission = iota
	Wholesaler
	Admin
)

type Price

type Price struct {
	Price          string `json:"price"`
	WholesalePrice string `json:"wholesale_price"`
}

func GetPrice

func GetPrice(name string) (Price, error)

type Product

type Product struct {
	Title       string `json:"-"`
	Cat         string `json:"-"`
	Subcat      string `json:"-"`
	Price       string `json:"-"`
	Total       string `json:"-"`
	Quantity    int    `json:"-"`
	Description string `json:"description"`
	ID          string `json:"id"`
	// contains filtered or unexported fields
}

func GetProducts

func GetProducts(cat, subcat string, opts ...func(*Product)) ([]Product, error)

func NewProduct

func NewProduct(title, cat, subcat string, opts ...func(*Product)) *Product

func (*Product) Add

func (p *Product) Add(r io.Reader) error

func (*Product) Delete

func (p *Product) Delete() error

func (*Product) Fetch

func (p *Product) Fetch() error

func (*Product) Update

func (p *Product) Update(p2 *Product) error

type Query

type Query struct {
	Key     []byte
	Buckets [][]byte
	Val     []byte
	Action  func([]byte) error
}

func NewQuery

func NewQuery(opts ...func(*Query)) Query

type Token

type Token struct {
	Email   string    `json:"email"`
	Expires time.Time `json:"expiers"`
}

type User

type User struct {
	Email string `schema:"email" json:"email"`
	//Wholesale stuff
	StoreName       string     `schema:"store_name" json:"store_name,omitempty"`
	DiscountCodeID  int        `schema:"discount_code_id" json:"discount_code_id,omitempty"`
	DiscountCode    string     `schema:"discount_code" json:"discount_code,omitempty"`
	Website         string     `schema:"website" json:"website,omitempty"`
	FirstName       string     `schema:"first_name" json:"first_name,omitempty"`
	LastName        string     `schema:"last_name" json:"last_name,omitempty"`
	Address         Address    `schema:"address" json:"address,omitempty"`
	ShippingAddress Address    `schema:"shipping_address" json:"shipping_address,omitempty"`
	Permission      Permission `json:"permission"`
	Password        string     `schema:"password" json:"-"`
	Password2       string     `schema:"confirm-password" json:"-"`
	HashedPassword  []byte     `json:"hashed_password,omitempty"`

	//They clicked on the verification email link
	Verified bool `json:"verified"`
	//Admin approval as a real wholesaler
	Confirmed bool `json:"confirmed,omitempty"`
}

func GetUserFromResetToken

func GetUserFromResetToken(key string, expire bool) (User, error)

func GetUsers

func GetUsers() ([]User, error)

func VerifyWholesaler

func VerifyWholesaler(token string) (User, error)

func (*User) CheckPassword

func (u *User) CheckPassword() (bool, error)

func (*User) Delete

func (u *User) Delete() error

func (*User) Fetch

func (u *User) Fetch() error

func (*User) GenerateToken

func (u *User) GenerateToken() (string, Query, error)

func (*User) Save

func (u *User) Save(moreRows ...Query) error

func (*User) UpdatePassword

func (u *User) UpdatePassword() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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