(ctx context.Context, name string)
| 43 | } |
| 44 | |
| 45 | func (r *OrganizationRepo) Create(ctx context.Context, name string) (*biz.Organization, error) { |
| 46 | ctx, span := otelx.Start(ctx, organizationRepoTracer, "OrganizationRepo.Create") |
| 47 | defer span.End() |
| 48 | |
| 49 | org, err := r.data.DB.Organization.Create(). |
| 50 | SetName(name). |
| 51 | Save(ctx) |
| 52 | if err != nil && ent.IsConstraintError(err) { |
| 53 | return nil, biz.NewErrAlreadyExists(err) |
| 54 | } else if err != nil { |
| 55 | return nil, err |
| 56 | } |
| 57 | |
| 58 | // Reloading the organization to get the proper created_at field from the DB |
| 59 | // Otherwise there is a mismatch between the created_at field in the DB (millisecods) and the one in the struct (nanoseconds) |
| 60 | return r.FindByID(ctx, org.ID) |
| 61 | } |
| 62 | |
| 63 | func (r *OrganizationRepo) FindByID(ctx context.Context, id uuid.UUID) (*biz.Organization, error) { |
| 64 | ctx, span := otelx.Start(ctx, organizationRepoTracer, "OrganizationRepo.FindByID") |
nothing calls this directly
no test coverage detected