MCPcopy Create free account
hub / github.com/rilldata/rill / InsertProjectMemberUser

Method InsertProjectMemberUser

admin/database/postgres/postgres.go:2355–2373  ·  view source on GitHub ↗
(ctx context.Context, projectID, userID, roleID string, restrictResources bool, resources []database.ResourceName)

Source from the content-addressed store, hash-verified

2353}
2354
2355func (c *connection) InsertProjectMemberUser(ctx context.Context, projectID, userID, roleID string, restrictResources bool, resources []database.ResourceName) error {
2356 resJSON, err := marshalResourceNames(resources)
2357 if err != nil {
2358 return err
2359 }
2360
2361 res, err := c.getDB(ctx).ExecContext(ctx, "INSERT INTO users_projects_roles (user_id, project_id, project_role_id, restrict_resources, resources) VALUES ($1, $2, $3, $4, $5)", userID, projectID, roleID, restrictResources, resJSON)
2362 if err != nil {
2363 return parseErr("project member", err)
2364 }
2365 rows, err := res.RowsAffected()
2366 if err != nil {
2367 return err
2368 }
2369 if rows == 0 {
2370 return fmt.Errorf("no rows affected when adding user to project")
2371 }
2372 return nil
2373}
2374
2375// FindOrganizationMemberUsergroups returns org user groups as a collection of MemberUsergroup.
2376// If a user group has no org role then RoleName is empty.

Callers

nothing calls this directly

Calls 5

getDBMethod · 0.95
marshalResourceNamesFunction · 0.85
parseErrFunction · 0.85
ErrorfMethod · 0.65
ExecContextMethod · 0.45

Tested by

no test coverage detected