MCPcopy Index your code
hub / github.com/rilldata/rill / InsertService

Method InsertService

admin/database/postgres/postgres.go:1418–1437  ·  view source on GitHub ↗

InsertService inserts a service.

(ctx context.Context, opts *database.InsertServiceOptions)

Source from the content-addressed store, hash-verified

1416
1417// InsertService inserts a service.
1418func (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.
1440func (c *connection) UpdateService(ctx context.Context, id string, opts *database.UpdateServiceOptions) (*database.Service, error) {

Callers

nothing calls this directly

Calls 4

getDBMethod · 0.95
serviceFromDTOMethod · 0.95
ValidateFunction · 0.92
parseErrFunction · 0.85

Tested by

no test coverage detected