Documentation ¶
Index ¶
- Variables
- type Price
- type Product
- type ProductQuery
- type ProductResultSet
- type ProductStore
- func (s *ProductStore) Find(query *ProductQuery) (*ProductResultSet, error)
- func (s *ProductStore) FindOne(query *ProductQuery) (*Product, error)
- func (s *ProductStore) Insert(doc *Product) error
- func (s *ProductStore) MustFind(query *ProductQuery) *ProductResultSet
- func (s *ProductStore) MustFindOne(query *ProductQuery) *Product
- func (s *ProductStore) New(name string, price Price, createdAt time.Time) (doc *Product, err error)
- func (s *ProductStore) Query() *ProductQuery
- func (s *ProductStore) Save(doc *Product) (updated bool, err error)
- func (s *ProductStore) Update(doc *Product) error
- type Status
Constants ¶
This section is empty.
Variables ¶
View Source
var Schema = schema{ Product: &schemaProduct{ Status: storable.NewField("status", "int"), CreatedAt: storable.NewField("createdat", "time.Time"), UpdatedAt: storable.NewField("updatedat", "time.Time"), Name: storable.NewField("name", "string"), Price: &schemaProductPrice{ 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 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 }
func (*Product) BeforeInsert ¶
func (*Product) BeforeSave ¶
type ProductQuery ¶
func (*ProductQuery) FindById ¶
func (q *ProductQuery) FindById(ids ...bson.ObjectId)
type ProductResultSet ¶
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 ¶
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) Insert ¶
func (s *ProductStore) Insert(doc *Product) error
func (*ProductStore) MustFind ¶
func (s *ProductStore) MustFind(query *ProductQuery) *ProductResultSet
func (*ProductStore) MustFindOne ¶
func (s *ProductStore) MustFindOne(query *ProductQuery) *Product
func (*ProductStore) Query ¶
func (s *ProductStore) Query() *ProductQuery
func (*ProductStore) Update ¶
func (s *ProductStore) Update(doc *Product) error
Click to show internal directories.
Click to hide internal directories.