20 lines
468 B
Go
20 lines
468 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type Cart struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
UserID uint `gorm:"index;not null" json:"user_id"`
|
|
ProductID uint `gorm:"index;not null" json:"product_id"`
|
|
Quantity int `gorm:"not null" json:"quantity"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Product Product `json:"product,omitempty"`
|
|
}
|
|
|
|
func (Cart) TableName() string {
|
|
return "carts"
|
|
}
|