Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associations references #150

Closed
wuqinqiang opened this issue Oct 19, 2021 · 1 comment
Closed

Associations references #150

wuqinqiang opened this issue Oct 19, 2021 · 1 comment
Assignees

Comments

@wuqinqiang
Copy link

Your Question

how to Override References?

When you assign credit cards to a user, GORM will save the user’s ID into credit cards’ UserNumber field.

type User struct {
gorm.Model
MemberNumber string
CreditCards []CreditCard gorm:"foreignKey:UserNumber"
}

type CreditCard struct {
gorm.Model
Number string
UserNumber string
}

Expected answer

i want able to change it with tag references, e.g:

type User struct {
gorm.Model
MemberNumber string
CreditCards []CreditCard gorm:"foreignKey:UserNumber;references:MemberNumber"
}

type CreditCard struct {
gorm.Model
Number string
UserNumber string
}

@wuqinqiang
Copy link
Author

wuqinqiang commented Oct 19, 2021

emmmmmm.
GORMTag: "references:xxx"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants