Skip to content

gorm.G[E](r.db).Count undefined 1.30.3 to 1.30.5 #7580

@yeferson59

Description

@yeferson59

GORM Playground Link

go-gorm/playground#1

Description

gorm v1.30.5 give error into method Count

gorm.GE.Count undefined (type gorm.Interface[E] has no field or method Count) (compiler MissingFieldOrMethod)

code production

func (r *BaseRepository[E, I]) List(ctx context.Context, limit, offset int) ([]*E, int64, error) {
	count, err := gorm.G[E](r.db).Count(ctx, "id")
	if err != nil {
		return nil, 0, err
	}

	entities, err := gorm.G[*E](r.db).Offset(offset).Limit(limit).Find(ctx)
	if err != nil {
		return nil, 0, err
	}

	return entities, count, nil
}

before v1.30.5 no error on v1.30.3 using API Generics

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions