gorm icon indicating copy to clipboard operation
gorm copied to clipboard

想要使用关联关系的时候 right join 怎么操作呀????

Open shcw opened this issue 2 years ago • 0 comments

想要使用关联关系的时候 right join 怎么操作呀

type Card struct {
	Id           int          `json:"id,omitempty" gorm:"column:id"`
	Amount       float64      `json:"amount,omitempty" gorm:"column:amount"`
	Currency     string       `json:"currency,omitempty" gorm:"column:currency"`
	GiftCard     Giftcard     `json:"giftCard,omitempty" gorm:"foreignKey:CardId"`
	CardConsumer CardConsumer `json:"consumer,omitempty" gorm:"foreignKey:CardId"`
}

// 这里只能 left join GiftCard 和left join CardConsumer  
// 如何实现 right join 
r.db.Joins("GiftCard").Joins("CardConsumer").Find(&card)

这里只能 left join GiftCard 和left join CardConsumer
如何实现 right join

#4872 @jinzhu

shcw avatar Aug 03 '22 11:08 shcw