28 lines
636 B
SQL
28 lines
636 B
SQL
-- name: GetBotCoOwner :one
|
|
SELECT * FROM bot_co_owners
|
|
WHERE bot_id = $1 AND user_id = $2;
|
|
|
|
-- name: ListCoOwnersByBot :many
|
|
SELECT u.*
|
|
FROM bot_co_owners bco
|
|
JOIN users u ON u.id = bco.user_id
|
|
WHERE bco.bot_id = $1;
|
|
|
|
-- name: ListBotsByCoOwner :many
|
|
SELECT b.*
|
|
FROM bot_co_owners bco
|
|
JOIN bots b ON b.id = bco.bot_id
|
|
WHERE bco.user_id = $1;
|
|
|
|
-- name: AddBotCoOwner :exec
|
|
INSERT INTO bot_co_owners (bot_id, user_id)
|
|
VALUES ($1, $2)
|
|
ON CONFLICT DO NOTHING;
|
|
|
|
-- name: RemoveBotCoOwner :exec
|
|
DELETE FROM bot_co_owners
|
|
WHERE bot_id = $1 AND user_id = $2;
|
|
|
|
-- name: RemoveAllCoOwnersByBot :exec
|
|
DELETE FROM bot_co_owners
|
|
WHERE bot_id = $1;
|