gostart/data/queries.sql.go

456 lines
10 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.16.0
// source: queries.sql
package data
import (
"context"
"database/sql"
)
const addIcon = `-- name: AddIcon :one
insert into icons (owner_id, url, content_type, data)
values (?, ?, ?, ?) returning id, owner_id, created_at, url, content_type, data
`
type AddIconParams struct {
OwnerID int64 `json:"owner_id"`
Url string `json:"url"`
ContentType string `json:"content_type"`
Data []byte `json:"data"`
}
func (q *Queries) AddIcon(ctx context.Context, arg AddIconParams) (Icon, error) {
row := q.db.QueryRowContext(ctx, addIcon,
arg.OwnerID,
arg.Url,
arg.ContentType,
arg.Data,
)
var i Icon
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Url,
&i.ContentType,
&i.Data,
)
return i, err
}
const addLink = `-- name: AddLink :one
insert into links (owner_id, url, name, logo_url)
values (?, ?, ?, ?) returning id, owner_id, created_at, url, name, logo_url
`
type AddLinkParams struct {
OwnerID int64 `json:"owner_id"`
Url string `json:"url"`
Name string `json:"name"`
LogoUrl sql.NullString `json:"logo_url"`
}
func (q *Queries) AddLink(ctx context.Context, arg AddLinkParams) (Link, error) {
row := q.db.QueryRowContext(ctx, addLink,
arg.OwnerID,
arg.Url,
arg.Name,
arg.LogoUrl,
)
var i Link
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Url,
&i.Name,
&i.LogoUrl,
)
return i, err
}
const addOwner = `-- name: AddOwner :one
insert into owners (id, name)
values (?, ?) returning id, created_at, name
`
type AddOwnerParams struct {
ID int64 `json:"id"`
Name string `json:"name"`
}
func (q *Queries) AddOwner(ctx context.Context, arg AddOwnerParams) (Owner, error) {
row := q.db.QueryRowContext(ctx, addOwner, arg.ID, arg.Name)
var i Owner
err := row.Scan(&i.ID, &i.CreatedAt, &i.Name)
return i, err
}
const addPullRequest = `-- name: AddPullRequest :one
insert into pull_requests (owner_id, number, repo, description)
values (?, ?, ?, ?) returning id, owner_id, created_at, number, repo, description, commitid
`
type AddPullRequestParams struct {
OwnerID int64 `json:"owner_id"`
Number int64 `json:"number"`
Repo string `json:"repo"`
Description sql.NullString `json:"description"`
}
func (q *Queries) AddPullRequest(ctx context.Context, arg AddPullRequestParams) (PullRequest, error) {
row := q.db.QueryRowContext(ctx, addPullRequest,
arg.OwnerID,
arg.Number,
arg.Repo,
arg.Description,
)
var i PullRequest
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Number,
&i.Repo,
&i.Description,
&i.Commitid,
)
return i, err
}
const addPullRequestIgnore = `-- name: AddPullRequestIgnore :one
insert into pull_request_ignores (owner_id, number, repo)
values (?, ?, ?) returning id, owner_id, created_at, number, repo
`
type AddPullRequestIgnoreParams struct {
OwnerID int64 `json:"owner_id"`
Number int64 `json:"number"`
Repo string `json:"repo"`
}
func (q *Queries) AddPullRequestIgnore(ctx context.Context, arg AddPullRequestIgnoreParams) (PullRequestIgnore, error) {
row := q.db.QueryRowContext(ctx, addPullRequestIgnore, arg.OwnerID, arg.Number, arg.Repo)
var i PullRequestIgnore
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Number,
&i.Repo,
)
return i, err
}
const addWatchItem = `-- name: AddWatchItem :one
insert into watch_items (owner_id, name, repo, descr)
values (?, ?, ?, ?) returning id, owner_id, created_at, name, repo, descr
`
type AddWatchItemParams struct {
OwnerID int64 `json:"owner_id"`
Name string `json:"name"`
Repo string `json:"repo"`
Descr sql.NullString `json:"descr"`
}
func (q *Queries) AddWatchItem(ctx context.Context, arg AddWatchItemParams) (WatchItem, error) {
row := q.db.QueryRowContext(ctx, addWatchItem,
arg.OwnerID,
arg.Name,
arg.Repo,
arg.Descr,
)
var i WatchItem
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Name,
&i.Repo,
&i.Descr,
)
return i, err
}
const deleteLink = `-- name: DeleteLink :exec
delete from links where id = ? and owner_id = ?
`
type DeleteLinkParams struct {
ID int64 `json:"id"`
OwnerID int64 `json:"owner_id"`
}
func (q *Queries) DeleteLink(ctx context.Context, arg DeleteLinkParams) error {
_, err := q.db.ExecContext(ctx, deleteLink, arg.ID, arg.OwnerID)
return err
}
const deletePullRequest = `-- name: DeletePullRequest :exec
delete from pull_requests where id = ? and owner_id = ?
`
type DeletePullRequestParams struct {
ID int64 `json:"id"`
OwnerID int64 `json:"owner_id"`
}
func (q *Queries) DeletePullRequest(ctx context.Context, arg DeletePullRequestParams) error {
_, err := q.db.ExecContext(ctx, deletePullRequest, arg.ID, arg.OwnerID)
return err
}
const deleteWatchItem = `-- name: DeleteWatchItem :exec
delete from watch_items where id = ? and owner_id = ?
`
type DeleteWatchItemParams struct {
ID int64 `json:"id"`
OwnerID int64 `json:"owner_id"`
}
func (q *Queries) DeleteWatchItem(ctx context.Context, arg DeleteWatchItemParams) error {
_, err := q.db.ExecContext(ctx, deleteWatchItem, arg.ID, arg.OwnerID)
return err
}
const getAllIcons = `-- name: GetAllIcons :many
select id, owner_id, created_at, url, content_type, data
from icons
where owner_id = ?
`
func (q *Queries) GetAllIcons(ctx context.Context, ownerID int64) ([]Icon, error) {
rows, err := q.db.QueryContext(ctx, getAllIcons, ownerID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Icon{}
for rows.Next() {
var i Icon
if err := rows.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Url,
&i.ContentType,
&i.Data,
); 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 getAllLinks = `-- name: GetAllLinks :many
select id, owner_id, created_at, url, name, logo_url
from links
where owner_id = ?
`
func (q *Queries) GetAllLinks(ctx context.Context, ownerID int64) ([]Link, error) {
rows, err := q.db.QueryContext(ctx, getAllLinks, ownerID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []Link{}
for rows.Next() {
var i Link
if err := rows.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Url,
&i.Name,
&i.LogoUrl,
); 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 getAllPullRequestIgnores = `-- name: GetAllPullRequestIgnores :many
select id, owner_id, created_at, number, repo
from pull_request_ignores
where owner_id = ?
`
func (q *Queries) GetAllPullRequestIgnores(ctx context.Context, ownerID int64) ([]PullRequestIgnore, error) {
rows, err := q.db.QueryContext(ctx, getAllPullRequestIgnores, ownerID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []PullRequestIgnore{}
for rows.Next() {
var i PullRequestIgnore
if err := rows.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Number,
&i.Repo,
); 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 getAllPullRequests = `-- name: GetAllPullRequests :many
select id, owner_id, created_at, number, repo, description, commitid
from pull_requests
where number not in (select number
from pull_request_ignores
where pull_request_ignores.owner_id = ?)
and pull_requests.owner_id = ?
`
type GetAllPullRequestsParams struct {
OwnerID int64 `json:"owner_id"`
OwnerID_2 int64 `json:"owner_id_2"`
}
func (q *Queries) GetAllPullRequests(ctx context.Context, arg GetAllPullRequestsParams) ([]PullRequest, error) {
rows, err := q.db.QueryContext(ctx, getAllPullRequests, arg.OwnerID, arg.OwnerID_2)
if err != nil {
return nil, err
}
defer rows.Close()
items := []PullRequest{}
for rows.Next() {
var i PullRequest
if err := rows.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Number,
&i.Repo,
&i.Description,
&i.Commitid,
); 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 getAllWatchItems = `-- name: GetAllWatchItems :many
select id, owner_id, created_at, name, repo, descr
from watch_items
`
func (q *Queries) GetAllWatchItems(ctx context.Context) ([]WatchItem, error) {
rows, err := q.db.QueryContext(ctx, getAllWatchItems)
if err != nil {
return nil, err
}
defer rows.Close()
items := []WatchItem{}
for rows.Next() {
var i WatchItem
if err := rows.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Name,
&i.Repo,
&i.Descr,
); 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 getAllWatchItemsByOwner = `-- name: GetAllWatchItemsByOwner :many
select id, owner_id, created_at, name, repo, descr
from watch_items
where owner_id = ?
`
func (q *Queries) GetAllWatchItemsByOwner(ctx context.Context, ownerID int64) ([]WatchItem, error) {
rows, err := q.db.QueryContext(ctx, getAllWatchItemsByOwner, ownerID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []WatchItem{}
for rows.Next() {
var i WatchItem
if err := rows.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Name,
&i.Repo,
&i.Descr,
); 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 getOwner = `-- name: GetOwner :one
select id, created_at, name
from owners
where id = ?
`
func (q *Queries) GetOwner(ctx context.Context, id int64) (Owner, error) {
row := q.db.QueryRowContext(ctx, getOwner, id)
var i Owner
err := row.Scan(&i.ID, &i.CreatedAt, &i.Name)
return i, err
}