Adds the capability to retrieve a property field by name (#30859)
* Adds the capability to retrieve a property field by name Allows to retrieve a property field by name and groupID. As the name is only unique within the context of a group, and we can have multiple fields with the same name in the store, for this method the groupID is directly included in the query instead of being an optional field. * Adds the targetID parameter to correctly filter fields * Ensure the method only retrieves non-deleted fields --------- Co-authored-by: Miguel de la Cruz <miguel@ctrlz.es> Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
64ed8f02dc
Коммит
6ab6a008e6
@@ -67,6 +67,21 @@ func (s *SqlPropertyFieldStore) Get(groupID, id string) (*model.PropertyField, e
|
||||
return &field, nil
|
||||
}
|
||||
|
||||
func (s *SqlPropertyFieldStore) GetFieldByName(groupID, targetID, name string) (*model.PropertyField, error) {
|
||||
builder := s.tableSelectQuery.
|
||||
Where(sq.Eq{"GroupID": groupID}).
|
||||
Where(sq.Eq{"TargetID": targetID}).
|
||||
Where(sq.Eq{"Name": name}).
|
||||
Where(sq.Eq{"DeleteAt": 0})
|
||||
|
||||
var field model.PropertyField
|
||||
if err := s.GetReplica().GetBuilder(&field, builder); err != nil {
|
||||
return nil, errors.Wrap(err, "property_field_get_by_name_select")
|
||||
}
|
||||
|
||||
return &field, nil
|
||||
}
|
||||
|
||||
func (s *SqlPropertyFieldStore) GetMany(groupID string, ids []string) ([]*model.PropertyField, error) {
|
||||
builder := s.tableSelectQuery.Where(sq.Eq{"id": ids})
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user