taskcafe/api/pg/project.sql.go

124 lines
2.6 KiB
Go
Raw Normal View History

2020-04-10 04:40:22 +02:00
// Code generated by sqlc. DO NOT EDIT.
// source: project.sql
package pg
import (
"context"
"time"
"github.com/google/uuid"
)
const createProject = `-- name: CreateProject :one
2020-04-20 05:02:55 +02:00
INSERT INTO project(owner, team_id, created_at, name) VALUES ($1, $2, $3, $4) RETURNING project_id, team_id, created_at, name, owner
2020-04-10 04:40:22 +02:00
`
type CreateProjectParams struct {
2020-04-20 05:02:55 +02:00
Owner uuid.UUID `json:"owner"`
2020-04-10 04:40:22 +02:00
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) {
2020-04-20 05:02:55 +02:00
row := q.db.QueryRowContext(ctx, createProject,
arg.Owner,
arg.TeamID,
arg.CreatedAt,
arg.Name,
)
2020-04-10 04:40:22 +02:00
var i Project
err := row.Scan(
&i.ProjectID,
&i.TeamID,
&i.CreatedAt,
&i.Name,
2020-04-20 05:02:55 +02:00
&i.Owner,
2020-04-10 04:40:22 +02:00
)
return i, err
}
const getAllProjects = `-- name: GetAllProjects :many
2020-04-20 05:02:55 +02:00
SELECT project_id, team_id, created_at, name, owner FROM project
2020-04-10 04:40:22 +02:00
`
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,
2020-04-20 05:02:55 +02:00
&i.Owner,
2020-04-10 04:40:22 +02:00
); 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
2020-04-20 05:02:55 +02:00
SELECT project_id, team_id, created_at, name, owner FROM project WHERE team_id = $1
2020-04-10 04:40:22 +02:00
`
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,
2020-04-20 05:02:55 +02:00
&i.Owner,
2020-04-10 04:40:22 +02:00
); 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
2020-04-20 05:02:55 +02:00
SELECT project_id, team_id, created_at, name, owner FROM project WHERE project_id = $1
2020-04-10 04:40:22 +02:00
`
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,
2020-04-20 05:02:55 +02:00
&i.Owner,
2020-04-10 04:40:22 +02:00
)
return i, err
}