MCPcopy Create free account
hub / github.com/bytebase/bytebase / DeleteGroup

Method DeleteGroup

backend/store/group.go:314–333  ·  view source on GitHub ↗

DeleteGroup deletes a group.

(ctx context.Context, workspace string, id string)

Source from the content-addressed store, hash-verified

312
313// DeleteGroup deletes a group.
314func (s *Store) DeleteGroup(ctx context.Context, workspace string, id string) error {
315 q := qb.Q().Space("DELETE FROM user_group WHERE id = ? AND workspace = ? RETURNING email", id, workspace)
316 query, args, err := q.ToSQL()
317 if err != nil {
318 return errors.Wrapf(err, "failed to build sql")
319 }
320
321 var email sql.NullString
322 if err := s.GetDB().QueryRowContext(ctx, query, args...).Scan(&email); err != nil {
323 return err
324 }
325
326 group := &GroupMessage{ID: id, Workspace: workspace}
327 if email.Valid {
328 group.Email = email.String
329 }
330 s.groupCache.Remove(getGroupCacheKey(workspace, group))
331 s.removeGroupMembersCache(workspace, group)
332 return nil
333}
334
335// RemoveMemberFromAllGroups removes a user from all groups in a workspace via a single SQL update.
336// member format is "users/{email}".

Callers

nothing calls this directly

Calls 7

GetDBMethod · 0.95
QFunction · 0.92
getGroupCacheKeyFunction · 0.85
SpaceMethod · 0.80
ToSQLMethod · 0.80
ScanMethod · 0.80

Tested by

no test coverage detected