optimus
optimus copied to clipboard
Store should fetch only the data for table and not do it for associations
In some of store methods, the data is queried from multiple tables, where we fetch the associations. This should not be required in most of the cases. We can simplify the code in such cases and reduce the n+1 query problem by gorm.
Example: in store/postgres/namespace_repository.go:119
if err := repo.db.WithContext(ctx).Preload("Project").Preload("Project.Secrets").
Where("name = ? AND project_id = ?", name, project.ID.UUID()).
First(&r).Error; err != nil {