// Code generated by sqlc. DO NOT EDIT. // source: project.sql package db import ( "context" "time" "github.com/google/uuid" ) const createProject = `-- name: CreateProject :one INSERT INTO project(owner, team_id, created_at, name) VALUES ($1, $2, $3, $4) RETURNING project_id, team_id, created_at, name, owner ` type CreateProjectParams struct { Owner uuid.UUID `json:"owner"` TeamID uuid.UUID `json:"team_id"` CreatedAt time.Time `json:"created_at"` Name string `json:"name"` } func (q *Queries) CreateProject(ctx context.Context, arg CreateProjectParams) (Project, error) { row := q.db.QueryRowContext(ctx, createProject, arg.Owner, arg.TeamID, arg.CreatedAt, arg.Name, ) var i Project err := row.Scan( &i.ProjectID, &i.TeamID, &i.CreatedAt, &i.Name, &i.Owner, ) return i, err } const createProjectMember = `-- name: CreateProjectMember :one INSERT INTO project_member (project_id, user_id, role_code, added_at) VALUES ($1, $2, $3, $4) RETURNING project_member_id, project_id, user_id, added_at, role_code ` type CreateProjectMemberParams struct { ProjectID uuid.UUID `json:"project_id"` UserID uuid.UUID `json:"user_id"` RoleCode string `json:"role_code"` AddedAt time.Time `json:"added_at"` } func (q *Queries) CreateProjectMember(ctx context.Context, arg CreateProjectMemberParams) (ProjectMember, error) { row := q.db.QueryRowContext(ctx, createProjectMember, arg.ProjectID, arg.UserID, arg.RoleCode, arg.AddedAt, ) var i ProjectMember err := row.Scan( &i.ProjectMemberID, &i.ProjectID, &i.UserID, &i.AddedAt, &i.RoleCode, ) return i, err } const deleteProjectByID = `-- name: DeleteProjectByID :exec DELETE FROM project WHERE project_id = $1 ` func (q *Queries) DeleteProjectByID(ctx context.Context, projectID uuid.UUID) error { _, err := q.db.ExecContext(ctx, deleteProjectByID, projectID) return err } const deleteProjectMember = `-- name: DeleteProjectMember :exec DELETE FROM project_member WHERE user_id = $1 AND project_id = $2 ` type DeleteProjectMemberParams struct { UserID uuid.UUID `json:"user_id"` ProjectID uuid.UUID `json:"project_id"` } func (q *Queries) DeleteProjectMember(ctx context.Context, arg DeleteProjectMemberParams) error { _, err := q.db.ExecContext(ctx, deleteProjectMember, arg.UserID, arg.ProjectID) return err } const getAllProjects = `-- name: GetAllProjects :many SELECT project_id, team_id, created_at, name, owner FROM project ` func (q *Queries) GetAllProjects(ctx context.Context) ([]Project, error) { rows, err := q.db.QueryContext(ctx, getAllProjects) if err != nil { return nil, err } defer rows.Close() var items []Project for rows.Next() { var i Project if err := rows.Scan( &i.ProjectID, &i.TeamID, &i.CreatedAt, &i.Name, &i.Owner, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getAllProjectsForTeam = `-- name: GetAllProjectsForTeam :many SELECT project_id, team_id, created_at, name, owner FROM project WHERE team_id = $1 ` func (q *Queries) GetAllProjectsForTeam(ctx context.Context, teamID uuid.UUID) ([]Project, error) { rows, err := q.db.QueryContext(ctx, getAllProjectsForTeam, teamID) if err != nil { return nil, err } defer rows.Close() var items []Project for rows.Next() { var i Project if err := rows.Scan( &i.ProjectID, &i.TeamID, &i.CreatedAt, &i.Name, &i.Owner, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getProjectByID = `-- name: GetProjectByID :one SELECT project_id, team_id, created_at, name, owner FROM project WHERE project_id = $1 ` func (q *Queries) GetProjectByID(ctx context.Context, projectID uuid.UUID) (Project, error) { row := q.db.QueryRowContext(ctx, getProjectByID, projectID) var i Project err := row.Scan( &i.ProjectID, &i.TeamID, &i.CreatedAt, &i.Name, &i.Owner, ) return i, err } const getProjectMembersForProjectID = `-- name: GetProjectMembersForProjectID :many SELECT project_member_id, project_id, user_id, added_at, role_code FROM project_member WHERE project_id = $1 ` func (q *Queries) GetProjectMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectMember, error) { rows, err := q.db.QueryContext(ctx, getProjectMembersForProjectID, projectID) if err != nil { return nil, err } defer rows.Close() var items []ProjectMember for rows.Next() { var i ProjectMember if err := rows.Scan( &i.ProjectMemberID, &i.ProjectID, &i.UserID, &i.AddedAt, &i.RoleCode, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const getRoleForProjectMemberByUserID = `-- name: GetRoleForProjectMemberByUserID :one SELECT code, role.name FROM project_member INNER JOIN role ON role.code = project_member.role_code WHERE user_id = $1 AND project_id = $2 ` type GetRoleForProjectMemberByUserIDParams struct { UserID uuid.UUID `json:"user_id"` ProjectID uuid.UUID `json:"project_id"` } func (q *Queries) GetRoleForProjectMemberByUserID(ctx context.Context, arg GetRoleForProjectMemberByUserIDParams) (Role, error) { row := q.db.QueryRowContext(ctx, getRoleForProjectMemberByUserID, arg.UserID, arg.ProjectID) var i Role err := row.Scan(&i.Code, &i.Name) return i, err } const setProjectOwner = `-- name: SetProjectOwner :one UPDATE project SET owner = $2 WHERE project_id = $1 RETURNING project_id, team_id, created_at, name, owner ` type SetProjectOwnerParams struct { ProjectID uuid.UUID `json:"project_id"` Owner uuid.UUID `json:"owner"` } func (q *Queries) SetProjectOwner(ctx context.Context, arg SetProjectOwnerParams) (Project, error) { row := q.db.QueryRowContext(ctx, setProjectOwner, arg.ProjectID, arg.Owner) var i Project err := row.Scan( &i.ProjectID, &i.TeamID, &i.CreatedAt, &i.Name, &i.Owner, ) return i, err } const updateProjectMemberRole = `-- name: UpdateProjectMemberRole :one UPDATE project_member SET role_code = $3 WHERE project_id = $1 AND user_id = $2 RETURNING project_member_id, project_id, user_id, added_at, role_code ` type UpdateProjectMemberRoleParams struct { ProjectID uuid.UUID `json:"project_id"` UserID uuid.UUID `json:"user_id"` RoleCode string `json:"role_code"` } func (q *Queries) UpdateProjectMemberRole(ctx context.Context, arg UpdateProjectMemberRoleParams) (ProjectMember, error) { row := q.db.QueryRowContext(ctx, updateProjectMemberRole, arg.ProjectID, arg.UserID, arg.RoleCode) var i ProjectMember err := row.Scan( &i.ProjectMemberID, &i.ProjectID, &i.UserID, &i.AddedAt, &i.RoleCode, ) return i, err } const updateProjectNameByID = `-- name: UpdateProjectNameByID :one UPDATE project SET name = $2 WHERE project_id = $1 RETURNING project_id, team_id, created_at, name, owner ` type UpdateProjectNameByIDParams struct { ProjectID uuid.UUID `json:"project_id"` Name string `json:"name"` } func (q *Queries) UpdateProjectNameByID(ctx context.Context, arg UpdateProjectNameByIDParams) (Project, error) { row := q.db.QueryRowContext(ctx, updateProjectNameByID, arg.ProjectID, arg.Name) var i Project err := row.Scan( &i.ProjectID, &i.TeamID, &i.CreatedAt, &i.Name, &i.Owner, ) return i, err }