67 lines
1.6 KiB
Go
67 lines
1.6 KiB
Go
|
// Code generated by sqlc. DO NOT EDIT.
|
||
|
// source: task_label.sql
|
||
|
|
||
|
package pg
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"time"
|
||
|
|
||
|
"github.com/google/uuid"
|
||
|
)
|
||
|
|
||
|
const createTaskLabelForTask = `-- name: CreateTaskLabelForTask :one
|
||
|
INSERT INTO task_label (task_id, label_color_id, assigned_date)
|
||
|
VALUES ($1, $2, $3) RETURNING task_label_id, task_id, label_color_id, assigned_date
|
||
|
`
|
||
|
|
||
|
type CreateTaskLabelForTaskParams struct {
|
||
|
TaskID uuid.UUID `json:"task_id"`
|
||
|
LabelColorID uuid.UUID `json:"label_color_id"`
|
||
|
AssignedDate time.Time `json:"assigned_date"`
|
||
|
}
|
||
|
|
||
|
func (q *Queries) CreateTaskLabelForTask(ctx context.Context, arg CreateTaskLabelForTaskParams) (TaskLabel, error) {
|
||
|
row := q.db.QueryRowContext(ctx, createTaskLabelForTask, arg.TaskID, arg.LabelColorID, arg.AssignedDate)
|
||
|
var i TaskLabel
|
||
|
err := row.Scan(
|
||
|
&i.TaskLabelID,
|
||
|
&i.TaskID,
|
||
|
&i.LabelColorID,
|
||
|
&i.AssignedDate,
|
||
|
)
|
||
|
return i, err
|
||
|
}
|
||
|
|
||
|
const getTaskLabelsForTaskID = `-- name: GetTaskLabelsForTaskID :many
|
||
|
SELECT task_label_id, task_id, label_color_id, assigned_date FROM task_label WHERE task_id = $1
|
||
|
`
|
||
|
|
||
|
func (q *Queries) GetTaskLabelsForTaskID(ctx context.Context, taskID uuid.UUID) ([]TaskLabel, error) {
|
||
|
rows, err := q.db.QueryContext(ctx, getTaskLabelsForTaskID, taskID)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
defer rows.Close()
|
||
|
var items []TaskLabel
|
||
|
for rows.Next() {
|
||
|
var i TaskLabel
|
||
|
if err := rows.Scan(
|
||
|
&i.TaskLabelID,
|
||
|
&i.TaskID,
|
||
|
&i.LabelColorID,
|
||
|
&i.AssignedDate,
|
||
|
); 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
|
||
|
}
|