gorm
gorm copied to clipboard
Sort has_many items
Is there a way to sort the items in a has-many-association? I have one model A that has many of B (fields: a, b, sort) and in B there is a variable to sort the items (sort). Is there a way to associate A.ID and B.a and get a list of B.b sorted by B.sort?
The document you expected this should be explained
https://gorm.io/docs/has_many.html
Expected answer
I currently solved this with an AfterFind.Hook but I hope there is a better (performing) solution