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

Method FindProjectsByNameAndUser

admin/database/postgres/postgres.go:424–438  ·  view source on GitHub ↗
(ctx context.Context, name, userID string)

Source from the content-addressed store, hash-verified

422}
423
424func (c *connection) FindProjectsByNameAndUser(ctx context.Context, name, userID string) ([]*database.Project, error) {
425 var res []*projectDTO
426 err := c.getDB(ctx).SelectContext(ctx, &res, `
427 SELECT * FROM projects
428 WHERE id IN (
429 SELECT upr.project_id FROM users_projects_roles upr WHERE upr.user_id = $1
430 UNION
431 SELECT ugpr.project_id FROM usergroups_projects_roles ugpr JOIN usergroups_users ugu ON ugpr.usergroup_id = ugu.usergroup_id WHERE ugu.user_id = $1
432 ) AND lower(name)=lower($2)
433 `, userID, name)
434 if err != nil {
435 return nil, parseErr("projects", err)
436 }
437 return c.projectsFromDTOs(res)
438}
439
440func (c *connection) InsertProject(ctx context.Context, opts *database.InsertProjectOptions) (*database.Project, error) {
441 if err := database.Validate(opts); err != nil {

Callers

nothing calls this directly

Calls 4

getDBMethod · 0.95
projectsFromDTOsMethod · 0.95
parseErrFunction · 0.85
SelectContextMethod · 0.80

Tested by

no test coverage detected