go - GORM Cannot pass foreign key to query -
i usin jinzhu gorm package connecting db, etc.
this code
package pizzas import ( "github.com/jinzhu/gorm" "github.com/gin-gonic/gin" "speedy-gonzales/db" "net/http" ) type pizza struct { gorm.model name string `gorm:"not null"` image string `sql:"type:text"` psizesandprices []pizzapricesize } type pizzapricesize struct { gorm.model sizetitle string `gorm:"column:size_title;type:varchar(50);not null'"` priceeur int `gorm:"column:price_eur"` pricebam int `gorm:"column:price_bam"` pizzaid uint `gorm:"index"` } func (pizzapricesize) tablename() string { return "pizza_price_sizes" } func fetchpizzaswithsizes(c *gin.context) { var pizza_model []pizza var p_sizes_prices_model []pizzapricesize db := db.dbconnect() db.debug().model(&pizza_model).related(&p_sizes_prices_model) c.json(http.statusok, gin.h{ "status": http.statusok, "message": p_sizes_prices_model, }) return }
when run app debug console: select * pizza_price_sizes
pizza_price_sizes
.deleted_at
null , ((pizza_id
= '0'))
my question how can pass pizza_id query?
Comments
Post a Comment