Update updates an existing group in the specified organization.
(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, opts *biz.UpdateGroupOpts)
| 367 | |
| 368 | // Update updates an existing group in the specified organization. |
| 369 | func (g GroupRepo) Update(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID, opts *biz.UpdateGroupOpts) (*biz.Group, error) { |
| 370 | ctx, span := otelx.Start(ctx, groupRepoTracer, "GroupRepo.Update") |
| 371 | defer span.End() |
| 372 | |
| 373 | if opts == nil { |
| 374 | return nil, biz.NewErrValidationStr("update group options cannot be nil") |
| 375 | } |
| 376 | |
| 377 | // Update the group with the provided options |
| 378 | entGroup, err := g.data.DB.Group.UpdateOneID(groupID). |
| 379 | SetNillableName(opts.NewName). |
| 380 | SetNillableDescription(opts.NewDescription). |
| 381 | SetUpdatedAt(time.Now()). |
| 382 | Where(group.OrganizationIDEQ(orgID), group.DeletedAtIsNil()). |
| 383 | Save(ctx) |
| 384 | if err != nil { |
| 385 | if ent.IsNotFound(err) { |
| 386 | return nil, biz.NewErrNotFound("group") |
| 387 | } |
| 388 | if ent.IsConstraintError(err) { |
| 389 | return nil, biz.NewErrAlreadyExistsStr("group with the same name already exists") |
| 390 | } |
| 391 | |
| 392 | return nil, err |
| 393 | } |
| 394 | |
| 395 | return g.FindByOrgAndID(ctx, orgID, entGroup.ID) |
| 396 | } |
| 397 | |
| 398 | // SoftDelete soft-deletes a group by setting the DeletedAt field to the current time. |
| 399 | // It also marks all group memberships as deleted and removes any pending invitations related to the group. |
nothing calls this directly
no test coverage detected