InsertService inserts a service.
(ctx context.Context, opts *database.InsertServiceOptions)
| 1416 | |
| 1417 | // InsertService inserts a service. |
| 1418 | func (c *connection) InsertService(ctx context.Context, opts *database.InsertServiceOptions) (*database.Service, error) { |
| 1419 | if err := database.Validate(opts); err != nil { |
| 1420 | return nil, err |
| 1421 | } |
| 1422 | |
| 1423 | if opts.Attributes == nil { |
| 1424 | opts.Attributes = make(map[string]any) |
| 1425 | } |
| 1426 | |
| 1427 | res := &serviceDTO{} |
| 1428 | err := c.getDB(ctx).QueryRowxContext(ctx, ` |
| 1429 | INSERT INTO service (org_id, name, attributes) |
| 1430 | VALUES ($1, $2, $3) RETURNING *`, |
| 1431 | opts.OrgID, opts.Name, opts.Attributes, |
| 1432 | ).StructScan(res) |
| 1433 | if err != nil { |
| 1434 | return nil, parseErr("service", err) |
| 1435 | } |
| 1436 | return res.serviceFromDTO() |
| 1437 | } |
| 1438 | |
| 1439 | // UpdateService updates a service. |
| 1440 | func (c *connection) UpdateService(ctx context.Context, id string, opts *database.UpdateServiceOptions) (*database.Service, error) { |
nothing calls this directly
no test coverage detected