taskcafe/api/pg/label_color.sql.go

82 lines
1.8 KiB
Go
Raw Normal View History

2020-04-20 05:02:55 +02:00
// Code generated by sqlc. DO NOT EDIT.
// source: label_color.sql
package pg
import (
"context"
"github.com/google/uuid"
)
2020-05-27 23:18:50 +02:00
const createLabelColor = `-- name: CreateLabelColor :one
INSERT INTO label_color (name, color_hex, position) VALUES ($1, $2, $3)
RETURNING label_color_id, color_hex, position, name
`
type CreateLabelColorParams struct {
Name string `json:"name"`
ColorHex string `json:"color_hex"`
Position float64 `json:"position"`
}
func (q *Queries) CreateLabelColor(ctx context.Context, arg CreateLabelColorParams) (LabelColor, error) {
row := q.db.QueryRowContext(ctx, createLabelColor, arg.Name, arg.ColorHex, arg.Position)
var i LabelColor
err := row.Scan(
&i.LabelColorID,
&i.ColorHex,
&i.Position,
&i.Name,
)
return i, err
}
2020-04-20 05:02:55 +02:00
const getLabelColorByID = `-- name: GetLabelColorByID :one
2020-05-27 23:18:50 +02:00
SELECT label_color_id, color_hex, position, name FROM label_color WHERE label_color_id = $1
2020-04-20 05:02:55 +02:00
`
func (q *Queries) GetLabelColorByID(ctx context.Context, labelColorID uuid.UUID) (LabelColor, error) {
row := q.db.QueryRowContext(ctx, getLabelColorByID, labelColorID)
var i LabelColor
2020-05-27 23:18:50 +02:00
err := row.Scan(
&i.LabelColorID,
&i.ColorHex,
&i.Position,
&i.Name,
)
2020-04-20 05:02:55 +02:00
return i, err
}
2020-05-27 23:18:50 +02:00
const getLabelColors = `-- name: GetLabelColors :many
SELECT label_color_id, color_hex, position, name FROM label_color
`
func (q *Queries) GetLabelColors(ctx context.Context) ([]LabelColor, error) {
rows, err := q.db.QueryContext(ctx, getLabelColors)
if err != nil {
return nil, err
}
defer rows.Close()
var items []LabelColor
for rows.Next() {
var i LabelColor
if err := rows.Scan(
&i.LabelColorID,
&i.ColorHex,
&i.Position,
&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
}