code: func (res *Resource) SetPrimaryFields(fields ...string) error {
  	scope := gorm.Scope{Value: res.Value}
  	res.PrimaryFields = nil
  
  	if len(fields) > 0 {
  		for _, fieldName := range fields {
  			if field, ok := scope.FieldByName(fieldName); ok {
  				res.PrimaryFields = append(res.PrimaryFields, field.StructField)
  			} else {
  				return fmt.Errorf("%v is not a valid field for resource %v", fieldName, res.Name)
  			}
  		}
  		return nil
  	}
  
  	if primaryField := scope.PrimaryField(); primaryField != nil {
  		res.PrimaryFields = []*gorm.StructField{primaryField.StructField}
  		return nil
  	}
  
  	return fmt.Errorf("no valid primary field for resource %v", res.Name)
  }
docs: // SetPrimaryFields set primary fields