GetProject returns the project with the given key. generator: project GetOne
(ctx context.Context, db dbtx, name string)
| 228 | // GetProject returns the project with the given key. |
| 229 | // generator: project GetOne |
| 230 | func GetProject(ctx context.Context, db dbtx, name string) (_ *Project, _err error) { |
| 231 | defer func() { |
| 232 | _err = mapErr(_err, "Project") |
| 233 | }() |
| 234 | |
| 235 | filter := ProjectFilter{} |
| 236 | filter.Name = &name |
| 237 | |
| 238 | objects, err := GetProjects(ctx, db, filter) |
| 239 | if err != nil { |
| 240 | return nil, fmt.Errorf("Failed to fetch from \"projects\" table: %w", err) |
| 241 | } |
| 242 | |
| 243 | switch len(objects) { |
| 244 | case 0: |
| 245 | return nil, ErrNotFound |
| 246 | case 1: |
| 247 | return &objects[0], nil |
| 248 | default: |
| 249 | return nil, fmt.Errorf("More than one \"projects\" entry matches") |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | // ProjectExists checks if a project with the given key exists. |
| 254 | // generator: project Exists |
searching dependent graphs…