From 54a4c10ed47eedc982230a876d0157cde34de405 Mon Sep 17 00:00:00 2001 From: Flavia Bastos Date: Sat, 30 May 2020 06:02:10 -0400 Subject: [PATCH] Document sqlTeamStore get methods (#14567) Co-authored-by: mattermod --- store/sqlstore/team_store.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/store/sqlstore/team_store.go b/store/sqlstore/team_store.go index 53dbdbf46c..57649e8752 100644 --- a/store/sqlstore/team_store.go +++ b/store/sqlstore/team_store.go @@ -292,6 +292,9 @@ func (s SqlTeamStore) Update(team *model.Team) (*model.Team, *model.AppError) { return team, nil } +// Get returns from the database the team that matches the id provided as parameter. +// If the team doesn't exist it returns a model.AppError with a +// http.StatusNotFound in the StatusCode field. func (s SqlTeamStore) Get(id string) (*model.Team, *model.AppError) { obj, err := s.GetReplica().Get(model.Team{}, id) if err != nil { @@ -304,6 +307,9 @@ func (s SqlTeamStore) Get(id string) (*model.Team, *model.AppError) { return obj.(*model.Team), nil } +// GetByInviteId returns from the database the team that matches the inviteId provided as parameter. +// If the parameter provided is empty or if there is no match in the database, it returns a model.AppError +// with a http.StatusNotFound in the StatusCode field. func (s SqlTeamStore) GetByInviteId(inviteId string) (*model.Team, *model.AppError) { team := model.Team{} @@ -318,6 +324,9 @@ func (s SqlTeamStore) GetByInviteId(inviteId string) (*model.Team, *model.AppErr return &team, nil } +// GetByName returns from the database the team that matches the name provided as parameter. +// If there is no match in the database, it returns a model.AppError with a +// http.StatusNotFound in the StatusCode field. func (s SqlTeamStore) GetByName(name string) (*model.Team, *model.AppError) { team := model.Team{} @@ -454,6 +463,7 @@ func (s SqlTeamStore) GetAllPage(offset int, limit int) ([]*model.Team, *model.A return teams, nil } +// GetTeamsByUserId returns from the database all teams that userId belongs to. func (s SqlTeamStore) GetTeamsByUserId(userId string) ([]*model.Team, *model.AppError) { var teams []*model.Team if _, err := s.GetReplica().Select(&teams, "SELECT Teams.* FROM Teams, TeamMembers WHERE TeamMembers.TeamId = Teams.Id AND TeamMembers.UserId = :UserId AND TeamMembers.DeleteAt = 0 AND Teams.DeleteAt = 0", map[string]interface{}{"UserId": userId}); err != nil { @@ -1090,6 +1100,8 @@ func (s SqlTeamStore) UpdateLastTeamIconUpdate(teamId string, curTime int64) *mo return nil } +// GetTeamsByScheme returns from the database all teams that match the schemeId provided as parameter, up to +// a total limit passed as paramater and paginated by offset number passed as parameter. func (s SqlTeamStore) GetTeamsByScheme(schemeId string, offset int, limit int) ([]*model.Team, *model.AppError) { var teams []*model.Team _, err := s.GetReplica().Select(&teams, "SELECT * FROM Teams WHERE SchemeId = :SchemeId ORDER BY DisplayName LIMIT :Limit OFFSET :Offset", map[string]interface{}{"SchemeId": schemeId, "Offset": offset, "Limit": limit})