example

package
v0.0.0-...-bc83711 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2015 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Schema = schema{
	Product: struct {
		Status    storable.Field
		CreatedAt storable.Field
		UpdatedAt storable.Field
		Name      storable.Field
		Price     struct {
			Amount   storable.Field
			Discount storable.Field
		}
		Discount storable.Field
		Url      storable.Field
		Tags     storable.Field
	}{
		Status:    storable.NewField("status", "int"),
		CreatedAt: storable.NewField("createdat", "time.Time"),
		UpdatedAt: storable.NewField("updatedat", "time.Time"),
		Name:      storable.NewField("name", "string"),
		Price: struct {
			Amount   storable.Field
			Discount storable.Field
		}{
			Amount:   storable.NewField("price.amount", "float64"),
			Discount: storable.NewField("price.discount", "float64"),
		},
		Discount: storable.NewField("discount", "float64"),
		Url:      storable.NewField("url", "string"),
		Tags:     storable.NewField("tags", "string"),
	},
}

Functions

This section is empty.

Types

type Price

type Price struct {
	Amount   float64
	Discount float64
}

type Product

type Product struct {
	storable.Document `bson:",inline" collection:"products"`

	Status    Status
	CreatedAt time.Time
	UpdatedAt time.Time
	Name      string
	Price     Price
	Discount  float64
	Url       string
	Tags      []string
}

type ProductQuery

type ProductQuery struct {
	storable.BaseQuery
}

func (*ProductQuery) FindById

func (q *ProductQuery) FindById(id bson.ObjectId)

type ProductResultSet

type ProductResultSet struct {
	storable.ResultSet
}

func (*ProductResultSet) All

func (r *ProductResultSet) All() ([]*Product, error)

func (*ProductResultSet) Next

func (r *ProductResultSet) Next() (*Product, error)

func (*ProductResultSet) One

func (r *ProductResultSet) One() (*Product, error)

type ProductStore

type ProductStore struct {
	storable.Store
}

func NewProductStore

func NewProductStore(db *mgo.Database) *ProductStore

func (*ProductStore) Find

func (s *ProductStore) Find(query *ProductQuery) (*ProductResultSet, error)

func (*ProductStore) FindOne

func (s *ProductStore) FindOne(query *ProductQuery) (*Product, error)

func (*ProductStore) New

func (s *ProductStore) New() *Product

func (*ProductStore) Query

func (s *ProductStore) Query() *ProductQuery

type Status

type Status int
const (
	Draft Status = iota
	Published
)

Jump to

Keyboard shortcuts

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