code: func (r *GormWorkItemRepository) Count(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression) (int, error) {
  	defer goa.MeasureSince([]string{"goa", "db", "workitem", "count"}, time.Now())
  
  	where, parameters, joins, compileError := Compile(criteria)
  	if compileError != nil {
  		return 0, errors.NewBadParameterError("expression", criteria)
  	}
  	where = where + " AND space_id = ?"
  	parameters = append(parameters, spaceID)
  
  	var count int
  	db := r.db.Model(&WorkItemStorage{}).Where(where, parameters...)
  	for _, j := range joins {
  		if err := j.Validate(db); err != nil {
  			log.Error(ctx, map[string]interface{}{"expression": criteria, "err": err}, "table join not valid")
  			return 0, errors.NewBadParameterError("expression", criteria).Expected("valid table join")
  		}
  		db = db.Joins(j.GetJoinExpression())
  	}
  	db = db.Count(&count)
  	if db.Error != nil {
  		return 0, errors.NewInternalError(ctx, errs.Wrapf(db.Error, "failed to count work items that match this criteria: %s", criteria))
  	}
  	return count, nil
  }
docs: // Count returns the amount of work item that satisfy the given criteria.Expression