I have a following data structure:
type Collection struct {
gorm.Model
Name string
CollectionItems []CollectionItem
}
type CollectionItem struct {
CollectionID uint
ItemID uint
Item
}
How can I query collections
table ordering results by a number of collection_item
associations i.e. collections with most items come first.
Thanks.