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
Correlate BelongTo #6961
Comments
Your current error is not a bug with the gorm framework, but a basic program compilation error. |
If you want to correlate the two, consider referencing the array of the other struct in the current struct type Group struct { The sample you can refer to : |
I know that is compilation error. in my case User model is belong to Group and Group model is belong to User and I don't have array and your answer is not the solution. |
Groups[0] is Groups |
Let me check it |
It returns |
please give me code sample, I'm at work right now and don't have much time to solve your problem, I will response you later 😅 |
thank you a lot for your response and happy for you that have a job :D https://github.com/pejman-hkh/gorn/blob/main/api/app/model/group.go |
checkout this: |
Let me describe better my problem. |
I solved this problem with made another package name with same model name with required fields. with helper model I can fetch each fields that I require. If type Group struct {
Title string `gorm:"size:255" json:"title"`
UserId uint `gorm:"index" json:"user_id"`
User struct {
Table string `gorm:"table:users"`
ID uint
Name string
}
}
|
@jinzhu you can close this issues |
Your Question
Consider we have a Group model, and Group model has
UserId
and User model hasGroupId
andUserId
too. How can I set User Belong to Group ?I go below error in golang compilation:
invalid recursive type Group
The document you expected this should be explained
Expected answer
The text was updated successfully, but these errors were encountered: