FindByOrgAndID retrieves a group by its ID and org, ensuring it is not deleted.
(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID)
| 306 | |
| 307 | // FindByOrgAndID retrieves a group by its ID and org, ensuring it is not deleted. |
| 308 | func (g GroupRepo) FindByOrgAndID(ctx context.Context, orgID uuid.UUID, groupID uuid.UUID) (*biz.Group, error) { |
| 309 | ctx, span := otelx.Start(ctx, groupRepoTracer, "GroupRepo.FindByOrgAndID") |
| 310 | defer span.End() |
| 311 | |
| 312 | entGroup, err := g.data.DB.Group.Query(). |
| 313 | Where(group.DeletedAtIsNil(), group.ID(groupID), group.OrganizationID(orgID)). |
| 314 | WithOrganization(). |
| 315 | Only(ctx) |
| 316 | if err != nil { |
| 317 | if ent.IsNotFound(err) { |
| 318 | return nil, biz.NewErrNotFound("group") |
| 319 | } |
| 320 | return nil, err |
| 321 | } |
| 322 | |
| 323 | return entGroupToBiz(entGroup), nil |
| 324 | } |
| 325 | |
| 326 | func (g GroupRepo) FindByOrgAndName(ctx context.Context, orgID uuid.UUID, name string) (*biz.Group, error) { |
| 327 | ctx, span := otelx.Start(ctx, groupRepoTracer, "GroupRepo.FindByOrgAndName") |
no test coverage detected