You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
4.4 KiB
197 lines
4.4 KiB
// Code generated by sqlc. DO NOT EDIT. |
|
// source: query.sql |
|
|
|
package db |
|
|
|
import ( |
|
"context" |
|
"database/sql" |
|
) |
|
|
|
const addFollower = `-- name: AddFollower :exec |
|
INSERT INTO ap_followers(iri, inbox, name, username, image) values($1, $2, $3, $4, $5) |
|
` |
|
|
|
type AddFollowerParams struct { |
|
Iri string |
|
Inbox string |
|
Name sql.NullString |
|
Username string |
|
Image sql.NullString |
|
} |
|
|
|
func (q *Queries) AddFollower(ctx context.Context, arg AddFollowerParams) error { |
|
_, err := q.db.ExecContext(ctx, addFollower, |
|
arg.Iri, |
|
arg.Inbox, |
|
arg.Name, |
|
arg.Username, |
|
arg.Image, |
|
) |
|
return err |
|
} |
|
|
|
const addToOutbox = `-- name: AddToOutbox :exec |
|
INSERT INTO ap_outbox(id, iri, value, type) values($1, $2, $3, $4) |
|
` |
|
|
|
type AddToOutboxParams struct { |
|
ID string |
|
Iri string |
|
Value []byte |
|
Type string |
|
} |
|
|
|
func (q *Queries) AddToOutbox(ctx context.Context, arg AddToOutboxParams) error { |
|
_, err := q.db.ExecContext(ctx, addToOutbox, |
|
arg.ID, |
|
arg.Iri, |
|
arg.Value, |
|
arg.Type, |
|
) |
|
return err |
|
} |
|
|
|
const getFederationFollowers = `-- name: GetFederationFollowers :many |
|
SELECT iri, inbox, name, username, image FROM ap_followers |
|
` |
|
|
|
type GetFederationFollowersRow struct { |
|
Iri string |
|
Inbox string |
|
Name sql.NullString |
|
Username string |
|
Image sql.NullString |
|
} |
|
|
|
func (q *Queries) GetFederationFollowers(ctx context.Context) ([]GetFederationFollowersRow, error) { |
|
rows, err := q.db.QueryContext(ctx, getFederationFollowers) |
|
if err != nil { |
|
return nil, err |
|
} |
|
defer rows.Close() |
|
var items []GetFederationFollowersRow |
|
for rows.Next() { |
|
var i GetFederationFollowersRow |
|
if err := rows.Scan( |
|
&i.Iri, |
|
&i.Inbox, |
|
&i.Name, |
|
&i.Username, |
|
&i.Image, |
|
); 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 getFollowerCount = `-- name: GetFollowerCount :one |
|
SElECT count(*) FROM ap_followers |
|
` |
|
|
|
func (q *Queries) GetFollowerCount(ctx context.Context) (int64, error) { |
|
row := q.db.QueryRowContext(ctx, getFollowerCount) |
|
var count int64 |
|
err := row.Scan(&count) |
|
return count, err |
|
} |
|
|
|
const getLocalPostCount = `-- name: GetLocalPostCount :one |
|
SElECT count(*) FROM ap_outbox |
|
` |
|
|
|
func (q *Queries) GetLocalPostCount(ctx context.Context) (int64, error) { |
|
row := q.db.QueryRowContext(ctx, getLocalPostCount) |
|
var count int64 |
|
err := row.Scan(&count) |
|
return count, err |
|
} |
|
|
|
const getObjectFromOutboxByID = `-- name: GetObjectFromOutboxByID :one |
|
SELECT value FROM ap_outbox WHERE id = $1 |
|
` |
|
|
|
func (q *Queries) GetObjectFromOutboxByID(ctx context.Context, id string) ([]byte, error) { |
|
row := q.db.QueryRowContext(ctx, getObjectFromOutboxByID, id) |
|
var value []byte |
|
err := row.Scan(&value) |
|
return value, err |
|
} |
|
|
|
const getObjectFromOutboxByIRI = `-- name: GetObjectFromOutboxByIRI :one |
|
SELECT value FROM ap_outbox WHERE iri = $1 |
|
` |
|
|
|
func (q *Queries) GetObjectFromOutboxByIRI(ctx context.Context, iri string) ([]byte, error) { |
|
row := q.db.QueryRowContext(ctx, getObjectFromOutboxByIRI, iri) |
|
var value []byte |
|
err := row.Scan(&value) |
|
return value, err |
|
} |
|
|
|
const getOutbox = `-- name: GetOutbox :many |
|
SELECT value FROM ap_outbox |
|
` |
|
|
|
func (q *Queries) GetOutbox(ctx context.Context) ([][]byte, error) { |
|
rows, err := q.db.QueryContext(ctx, getOutbox) |
|
if err != nil { |
|
return nil, err |
|
} |
|
defer rows.Close() |
|
var items [][]byte |
|
for rows.Next() { |
|
var value []byte |
|
if err := rows.Scan(&value); err != nil { |
|
return nil, err |
|
} |
|
items = append(items, value) |
|
} |
|
if err := rows.Close(); err != nil { |
|
return nil, err |
|
} |
|
if err := rows.Err(); err != nil { |
|
return nil, err |
|
} |
|
return items, nil |
|
} |
|
|
|
const removeFollowerByIRI = `-- name: RemoveFollowerByIRI :exec |
|
DELETE FROM ap_followers WHERE iri = $1 |
|
` |
|
|
|
func (q *Queries) RemoveFollowerByIRI(ctx context.Context, iri string) error { |
|
_, err := q.db.ExecContext(ctx, removeFollowerByIRI, iri) |
|
return err |
|
} |
|
|
|
const updateFollowerByIRI = `-- name: UpdateFollowerByIRI :exec |
|
UPDATE ap_followers SET inbox = $1, name = $2, username = $3, image = $4 WHERE iri = $5 |
|
` |
|
|
|
type UpdateFollowerByIRIParams struct { |
|
Inbox string |
|
Name sql.NullString |
|
Username string |
|
Image sql.NullString |
|
Iri string |
|
} |
|
|
|
func (q *Queries) UpdateFollowerByIRI(ctx context.Context, arg UpdateFollowerByIRIParams) error { |
|
_, err := q.db.ExecContext(ctx, updateFollowerByIRI, |
|
arg.Inbox, |
|
arg.Name, |
|
arg.Username, |
|
arg.Image, |
|
arg.Iri, |
|
) |
|
return err |
|
}
|
|
|