gostart/data/queries.sql.go

541 lines
11 KiB
Go
Raw Normal View History

2022-11-29 19:55:00 -07:00
// Code generated by sqlc. DO NOT EDIT.
// versions:
2023-05-18 12:54:16 -06:00
// sqlc v1.18.0
2022-11-29 19:55:00 -07:00
// source: queries.sql
package data
import (
"context"
)
2022-12-02 20:53:05 -07:00
const addIcon = `-- name: AddIcon :exec
insert
into icons (owner_id, link_id, content_type, data)
values (?, ?, ?, ?) on conflict(link_id) do
update set data = excluded.data, content_type = excluded.content_type
2022-11-29 19:55:00 -07:00
`
type AddIconParams struct {
OwnerID int64 `json:"owner_id"`
2022-12-02 20:53:05 -07:00
LinkID int64 `json:"link_id"`
2022-11-29 19:55:00 -07:00
ContentType string `json:"content_type"`
Data []byte `json:"data"`
}
2022-12-02 20:53:05 -07:00
func (q *Queries) AddIcon(ctx context.Context, arg AddIconParams) error {
_, err := q.db.ExecContext(ctx, addIcon,
2022-11-29 19:55:00 -07:00
arg.OwnerID,
2022-12-02 20:53:05 -07:00
arg.LinkID,
2022-11-29 19:55:00 -07:00
arg.ContentType,
arg.Data,
)
2022-12-02 20:53:05 -07:00
return err
2022-11-29 19:55:00 -07:00
}
const addLink = `-- name: AddLink :one
2022-12-21 19:21:40 -07:00
insert into links (owner_id, url, name, logo_url, shared)
values (?, ?, ?, ?, ?) returning id, owner_id, created_at, url, name, clicked, logo_url, shared
2022-11-29 19:55:00 -07:00
`
type AddLinkParams struct {
2022-12-02 20:53:05 -07:00
OwnerID int64 `json:"owner_id"`
Url string `json:"url"`
Name string `json:"name"`
LogoUrl string `json:"logo_url"`
2022-12-21 19:21:40 -07:00
Shared bool `json:"shared"`
2022-11-29 19:55:00 -07:00
}
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,
2022-12-21 19:21:40 -07:00
arg.Shared,
2022-11-29 19:55:00 -07:00
)
var i Link
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Url,
&i.Name,
2022-12-02 20:53:05 -07:00
&i.Clicked,
2022-11-29 19:55:00 -07:00
&i.LogoUrl,
2022-12-21 19:21:40 -07:00
&i.Shared,
2022-11-29 19:55:00 -07:00
)
return i, err
}
const addOwner = `-- name: AddOwner :one
insert into owners (id, name, show_shared)
values (?, ?, ?) returning id, created_at, last_used, name, show_shared
2022-11-29 19:55:00 -07:00
`
type AddOwnerParams struct {
ID int64 `json:"id"`
Name string `json:"name"`
ShowShared bool `json:"show_shared"`
2022-11-29 19:55:00 -07:00
}
func (q *Queries) AddOwner(ctx context.Context, arg AddOwnerParams) (Owner, error) {
row := q.db.QueryRowContext(ctx, addOwner, arg.ID, arg.Name, arg.ShowShared)
2022-11-29 19:55:00 -07:00
var i Owner
2022-12-02 20:53:05 -07:00
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.LastUsed,
&i.Name,
&i.ShowShared,
2022-12-02 20:53:05 -07:00
)
2022-11-29 19:55:00 -07:00
return i, err
}
const addPullRequest = `-- name: AddPullRequest :one
insert into pull_requests (owner_id, number, repo, description, url)
values (?, ?, ?, ?, ?) returning id, owner_id, created_at, number, repo, url, description, commitid
2022-11-29 19:55:00 -07:00
`
type AddPullRequestParams struct {
2022-12-02 20:53:05 -07:00
OwnerID int64 `json:"owner_id"`
Number int64 `json:"number"`
Repo string `json:"repo"`
Description string `json:"description"`
Url string `json:"url"`
2022-11-29 19:55:00 -07:00
}
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,
arg.Url,
2022-11-29 19:55:00 -07:00
)
var i PullRequest
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Number,
&i.Repo,
&i.Url,
2022-11-29 19:55:00 -07:00
&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
2022-12-02 20:53:05 -07:00
insert into watch_items (owner_id, name, repo)
values (?, ?, ?) returning id, owner_id, created_at, name, repo
2022-11-29 19:55:00 -07:00
`
type AddWatchItemParams struct {
2022-12-02 20:53:05 -07:00
OwnerID int64 `json:"owner_id"`
Name string `json:"name"`
Repo string `json:"repo"`
2022-11-29 19:55:00 -07:00
}
func (q *Queries) AddWatchItem(ctx context.Context, arg AddWatchItemParams) (WatchItem, error) {
2022-12-02 20:53:05 -07:00
row := q.db.QueryRowContext(ctx, addWatchItem, arg.OwnerID, arg.Name, arg.Repo)
2022-11-29 19:55:00 -07:00
var i WatchItem
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Name,
&i.Repo,
2022-11-29 19:55:00 -07:00
)
return i, err
}
const deleteLink = `-- name: DeleteLink :exec
2022-12-02 20:53:05 -07:00
delete
from links
where id = ?
and owner_id = ?
2022-11-29 19:55:00 -07:00
`
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
2022-12-02 20:53:05 -07:00
delete
from pull_requests
where id = ?
and owner_id = ?
2022-11-29 19:55:00 -07:00
`
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
2022-12-02 20:53:05 -07:00
delete
from watch_items
where id = ?
and owner_id = ?
2022-11-29 19:55:00 -07:00
`
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
2022-12-02 20:53:05 -07:00
select owner_id, link_id, created_at, content_type, data
2022-11-29 19:55:00 -07:00
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.OwnerID,
2022-12-02 20:53:05 -07:00
&i.LinkID,
2022-11-29 19:55:00 -07:00
&i.CreatedAt,
&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
2022-12-21 19:21:40 -07:00
select id, owner_id, created_at, url, name, clicked, logo_url, shared
2022-12-02 20:53:05 -07:00
from links
`
func (q *Queries) GetAllLinks(ctx context.Context) ([]Link, error) {
rows, err := q.db.QueryContext(ctx, getAllLinks)
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.Clicked,
&i.LogoUrl,
2022-12-21 19:21:40 -07:00
&i.Shared,
2022-12-02 20:53:05 -07: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 getAllLinksForOwner = `-- name: GetAllLinksForOwner :many
2022-12-21 19:21:40 -07:00
select id, owner_id, created_at, url, name, clicked, logo_url, shared
2022-11-29 19:55:00 -07:00
from links
where owner_id = ?
or shared = true
2022-11-29 19:55:00 -07:00
`
2022-12-02 20:53:05 -07:00
func (q *Queries) GetAllLinksForOwner(ctx context.Context, ownerID int64) ([]Link, error) {
rows, err := q.db.QueryContext(ctx, getAllLinksForOwner, ownerID)
2022-11-29 19:55:00 -07:00
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,
2022-12-02 20:53:05 -07:00
&i.Clicked,
2022-11-29 19:55:00 -07:00
&i.LogoUrl,
2022-12-21 19:21:40 -07:00
&i.Shared,
2022-11-29 19:55:00 -07: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 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, url, description, commitid
2022-11-29 19:55:00 -07:00
from pull_requests
where owner_id = ?
2022-11-29 19:55:00 -07:00
`
func (q *Queries) GetAllPullRequests(ctx context.Context, ownerID int64) ([]PullRequest, error) {
rows, err := q.db.QueryContext(ctx, getAllPullRequests, ownerID)
2022-11-29 19:55:00 -07:00
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.Url,
2022-11-29 19:55:00 -07:00
&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
2022-12-02 20:53:05 -07:00
select id, owner_id, created_at, name, repo
2022-11-29 19:55:00 -07:00
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,
2022-11-29 19:55:00 -07: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 getAllWatchItemsByOwner = `-- name: GetAllWatchItemsByOwner :many
2022-12-02 20:53:05 -07:00
select id, owner_id, created_at, name, repo
2022-11-29 19:55:00 -07:00
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,
2022-11-29 19:55:00 -07: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
}
2022-12-02 20:53:05 -07:00
const getIconByLinkID = `-- name: GetIconByLinkID :one
select owner_id, link_id, created_at, content_type, data
from icons
2022-12-24 05:50:23 -07:00
where link_id = ?
2022-12-02 20:53:05 -07:00
`
2022-12-24 05:50:23 -07:00
func (q *Queries) GetIconByLinkID(ctx context.Context, linkID int64) (Icon, error) {
row := q.db.QueryRowContext(ctx, getIconByLinkID, linkID)
2022-12-02 20:53:05 -07:00
var i Icon
err := row.Scan(
&i.OwnerID,
&i.LinkID,
&i.CreatedAt,
&i.ContentType,
&i.Data,
)
return i, err
}
2022-12-05 15:45:39 -07:00
const getLinkByID = `-- name: GetLinkByID :one
select id, owner_id, created_at, url, name, clicked, logo_url, shared
from links
where id = ?
2022-12-05 15:45:39 -07:00
`
func (q *Queries) GetLinkByID(ctx context.Context, id int64) (Link, error) {
row := q.db.QueryRowContext(ctx, getLinkByID, id)
var i Link
err := row.Scan(
&i.ID,
&i.OwnerID,
&i.CreatedAt,
&i.Url,
&i.Name,
&i.Clicked,
&i.LogoUrl,
2022-12-21 19:21:40 -07:00
&i.Shared,
2022-12-05 15:45:39 -07:00
)
return i, err
}
2022-11-29 19:55:00 -07:00
const getOwner = `-- name: GetOwner :one
select id, created_at, last_used, name, show_shared
2022-11-29 19:55:00 -07:00
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
2022-12-02 20:53:05 -07:00
err := row.Scan(
&i.ID,
&i.CreatedAt,
&i.LastUsed,
&i.Name,
&i.ShowShared,
2022-12-02 20:53:05 -07:00
)
2022-11-29 19:55:00 -07:00
return i, err
}