Skip to content

Instantly share code, notes, and snippets.

@dipeshhkc
Last active May 22, 2021 10:32
Show Gist options
  • Save dipeshhkc/df01de41b1cc63db44214bc291ed86c8 to your computer and use it in GitHub Desktop.
Save dipeshhkc/df01de41b1cc63db44214bc291ed86c8 to your computer and use it in GitHub Desktop.
package model
import (
"github.com/jinzhu/gorm"
)
type Order struct {
gorm.Model
User User `gorm:"foreignkey:UserID"`
Product Product `gorm:"foreignkey:ProductID"`
UserID uint
ProductID uint
Quantity int `json:"quantity"`
}
func (Order) TableName() string {
return "orders"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment