Skip to content

Instantly share code, notes, and snippets.

@BK1031
Last active July 16, 2024 01:26
Show Gist options
  • Save BK1031/673fd80490f34df15d41b6a1cfd397eb to your computer and use it in GitHub Desktop.
Save BK1031/673fd80490f34df15d41b6a1cfd397eb to your computer and use it in GitHub Desktop.
singlestore-go-bookstore order structs
package model
import "time"
type Order struct {
ID int `json:"id" gorm:"primaryKey,autoIncrement"`
Total float64 `json:"total"`
Items []OrderItem `json:"items" gorm:"-"`
CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime,precision:6"`
}
type OrderItem struct {
OrderID int `json:"order_id" gorm:"primaryKey"`
BookID int `json:"book_id" gorm:"primaryKey"`
Book Book `json:"book" gorm:"-"`
Quantity int `json:"quantity"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment