93 lines
2.3 KiB
Go
93 lines
2.3 KiB
Go
|
// Code generated by sqlc. DO NOT EDIT.
|
||
|
// source: project_label.sql
|
||
|
|
||
|
package pg
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"database/sql"
|
||
|
"time"
|
||
|
|
||
|
"github.com/google/uuid"
|
||
|
)
|
||
|
|
||
|
const createProjectLabel = `-- name: CreateProjectLabel :one
|
||
|
INSERT INTO project_label (project_id, label_color_id, created_date, name)
|
||
|
VALUES ($1, $2, $3, $4) RETURNING project_label_id, project_id, label_color_id, created_date, name
|
||
|
`
|
||
|
|
||
|
type CreateProjectLabelParams struct {
|
||
|
ProjectID uuid.UUID `json:"project_id"`
|
||
|
LabelColorID uuid.UUID `json:"label_color_id"`
|
||
|
CreatedDate time.Time `json:"created_date"`
|
||
|
Name sql.NullString `json:"name"`
|
||
|
}
|
||
|
|
||
|
func (q *Queries) CreateProjectLabel(ctx context.Context, arg CreateProjectLabelParams) (ProjectLabel, error) {
|
||
|
row := q.db.QueryRowContext(ctx, createProjectLabel,
|
||
|
arg.ProjectID,
|
||
|
arg.LabelColorID,
|
||
|
arg.CreatedDate,
|
||
|
arg.Name,
|
||
|
)
|
||
|
var i ProjectLabel
|
||
|
err := row.Scan(
|
||
|
&i.ProjectLabelID,
|
||
|
&i.ProjectID,
|
||
|
&i.LabelColorID,
|
||
|
&i.CreatedDate,
|
||
|
&i.Name,
|
||
|
)
|
||
|
return i, err
|
||
|
}
|
||
|
|
||
|
const getProjectLabelByID = `-- name: GetProjectLabelByID :one
|
||
|
SELECT project_label_id, project_id, label_color_id, created_date, name FROM project_label WHERE project_label_id = $1
|
||
|
`
|
||
|
|
||
|
func (q *Queries) GetProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) (ProjectLabel, error) {
|
||
|
row := q.db.QueryRowContext(ctx, getProjectLabelByID, projectLabelID)
|
||
|
var i ProjectLabel
|
||
|
err := row.Scan(
|
||
|
&i.ProjectLabelID,
|
||
|
&i.ProjectID,
|
||
|
&i.LabelColorID,
|
||
|
&i.CreatedDate,
|
||
|
&i.Name,
|
||
|
)
|
||
|
return i, err
|
||
|
}
|
||
|
|
||
|
const getProjectLabelsForProject = `-- name: GetProjectLabelsForProject :many
|
||
|
SELECT project_label_id, project_id, label_color_id, created_date, name FROM project_label WHERE project_id = $1
|
||
|
`
|
||
|
|
||
|
func (q *Queries) GetProjectLabelsForProject(ctx context.Context, projectID uuid.UUID) ([]ProjectLabel, error) {
|
||
|
rows, err := q.db.QueryContext(ctx, getProjectLabelsForProject, projectID)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
defer rows.Close()
|
||
|
var items []ProjectLabel
|
||
|
for rows.Next() {
|
||
|
var i ProjectLabel
|
||
|
if err := rows.Scan(
|
||
|
&i.ProjectLabelID,
|
||
|
&i.ProjectID,
|
||
|
&i.LabelColorID,
|
||
|
&i.CreatedDate,
|
||
|
&i.Name,
|
||
|
); 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
|
||
|
}
|