26 lines
559 B
Go
26 lines
559 B
Go
|
package model
|
||
|
|
||
|
import (
|
||
|
"github.com/Kamva/mgm/v3"
|
||
|
)
|
||
|
|
||
|
// Product type
|
||
|
type Product struct {
|
||
|
mgm.DefaultModel `bson:",inline"`
|
||
|
Name string `json:"name" bson:"name" validate:"required"`
|
||
|
Price float64 `json:"price" bson:"price" validate:"required"`
|
||
|
VAT int `json:"vat" bson:"vat" validate:"required"`
|
||
|
}
|
||
|
|
||
|
// Products Collection
|
||
|
type Products []Product
|
||
|
|
||
|
// NewProduct create new Product
|
||
|
func NewProduct(name string, price float64, vat int) *Product {
|
||
|
return &Product{
|
||
|
Name: name,
|
||
|
Price: price,
|
||
|
VAT: vat,
|
||
|
}
|
||
|
}
|