// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: bot_co_owners.sql package db import ( "context" ) const addBotCoOwner = `-- name: AddBotCoOwner :exec INSERT INTO bot_co_owners (bot_id, user_id) VALUES ($1, $2) ON CONFLICT DO NOTHING ` type AddBotCoOwnerParams struct { BotID string `json:"bot_id"` UserID string `json:"user_id"` } func (q *Queries) AddBotCoOwner(ctx context.Context, arg AddBotCoOwnerParams) error { _, err := q.db.Exec(ctx, addBotCoOwner, arg.BotID, arg.UserID) return err } const getBotCoOwner = `-- name: GetBotCoOwner :one SELECT bot_id, user_id FROM bot_co_owners WHERE bot_id = $1 AND user_id = $2 ` type GetBotCoOwnerParams struct { BotID string `json:"bot_id"` UserID string `json:"user_id"` } func (q *Queries) GetBotCoOwner(ctx context.Context, arg GetBotCoOwnerParams) (*BotCoOwner, error) { row := q.db.QueryRow(ctx, getBotCoOwner, arg.BotID, arg.UserID) var i BotCoOwner err := row.Scan(&i.BotID, &i.UserID) return &i, err } const listBotsByCoOwner = `-- name: ListBotsByCoOwner :many SELECT b.id, b.username, b.avatar, b.overview, b.description, b.is_slash, b.install_context, b.guild_count, b.install_count, b.imported_from, b.prefix, b.created_at, b.updated_at, b.status, b.main_owner_id FROM bot_co_owners bco JOIN bots b ON b.id = bco.bot_id WHERE bco.user_id = $1 ` func (q *Queries) ListBotsByCoOwner(ctx context.Context, userID string) ([]*Bot, error) { rows, err := q.db.Query(ctx, listBotsByCoOwner, userID) if err != nil { return nil, err } defer rows.Close() items := []*Bot{} for rows.Next() { var i Bot if err := rows.Scan( &i.ID, &i.Username, &i.Avatar, &i.Overview, &i.Description, &i.IsSlash, &i.InstallContext, &i.GuildCount, &i.InstallCount, &i.ImportedFrom, &i.Prefix, &i.CreatedAt, &i.UpdatedAt, &i.Status, &i.MainOwnerID, ); err != nil { return nil, err } items = append(items, &i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const listCoOwnersByBot = `-- name: ListCoOwnersByBot :many SELECT u.id, u.username, u.biography FROM bot_co_owners bco JOIN users u ON u.id = bco.user_id WHERE bco.bot_id = $1 ` func (q *Queries) ListCoOwnersByBot(ctx context.Context, botID string) ([]*User, error) { rows, err := q.db.Query(ctx, listCoOwnersByBot, botID) if err != nil { return nil, err } defer rows.Close() items := []*User{} for rows.Next() { var i User if err := rows.Scan(&i.ID, &i.Username, &i.Biography); err != nil { return nil, err } items = append(items, &i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const removeAllCoOwnersByBot = `-- name: RemoveAllCoOwnersByBot :exec DELETE FROM bot_co_owners WHERE bot_id = $1 ` func (q *Queries) RemoveAllCoOwnersByBot(ctx context.Context, botID string) error { _, err := q.db.Exec(ctx, removeAllCoOwnersByBot, botID) return err } const removeBotCoOwner = `-- name: RemoveBotCoOwner :exec DELETE FROM bot_co_owners WHERE bot_id = $1 AND user_id = $2 ` type RemoveBotCoOwnerParams struct { BotID string `json:"bot_id"` UserID string `json:"user_id"` } func (q *Queries) RemoveBotCoOwner(ctx context.Context, arg RemoveBotCoOwnerParams) error { _, err := q.db.Exec(ctx, removeBotCoOwner, arg.BotID, arg.UserID) return err }