We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi,
I have the following models
type StudentProfileModel struct { Id string `bson:"_id,omitempty" jsonapi:"primary,studentprofiles"` StudentId bson.ObjectId `bson:"lead_id" jsonapi:"attr,student_id"` Student *StudentModel `jsonapi:"relation,student"` }
type StudentModel struct { ID string `bson:"_id,omitempty" jsonapi:"primary,students"` Email string `bson:"email" jsonapi:"attr,email"` Password string `bson:"password" jsonapi:"attr,password"` StudentProfile *StudentProfileModel `jsonapi:"relation,studentprofile"` }
I face a problem when I am trying to fetch StudentProfile .
StudentProfile
Here is the code
studentProfileService := servicefactory.NewStudentProfileService() studentProfileModel := studentProfileService.GetStudentProfileById(studentProfileId) studentService := servicefactory.NewStudentService() studentModel := studentService.GetStudentById(studentProfileModel.StudentId.Hex()) // Attaching student profile to studentModel studentModel.StudentProfile = studentProfileModel // Attaching above fetched student model in student profile studentProfileModel.Student = studentModel return studentProfileModel
// Infinite loop here because of cyclic dependencies jsonapi.MarshalPayload(buff, studentProfile)
How to resolve this issue ?
I have read an article on jsonapi.org where suggest we can fetch recursive data
JSONAPI Recommendation
GET /comments HTTP/1.1 { "data": [{ "type": "comments", "id": "1", "attributes": { "text": "HATEOS are the thing!" }, "links": { "self": "/comments/1" }, "relationships": { "author": { "links": { "self": "/comments/1/relationships/author", "related": "/comments/1/author" } }, "articles": { "links": { "self": "/comments/1/relationships/articles", "related": "/comments/1/articles" } } } }], "links": { "self": "/comments" } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi,
I have the following models
I face a problem when I am trying to fetch
StudentProfile
.Here is the code
How to resolve this issue ?
I have read an article on jsonapi.org where suggest we can fetch recursive data
JSONAPI Recommendation
The text was updated successfully, but these errors were encountered: