-- name: CreateUserBroadCast :one
INSERT INTO user_broadcast (
    usertype,
    message
 ) VALUES (
    $1, $2
 ) RETURNING *;


-- name: CreateProcessBroadCast :one
INSERT INTO process_broadcast (
    process,
    emails,
    status
 ) VALUES (
    $1, 
    $2,
    $3
 ) RETURNING *;


-- name: ListUserBroadCasts :many
SELECT * from user_broadcast
ORDER BY id DESC LIMIT $1
OFFSET $2;

-- name: ListProcessBroadCasts :many
SELECT * from process_broadcast
ORDER BY id DESC 
LIMIT $1
OFFSET $2;

-- name: DeleteUserBroadCast :exec
DELETE FROM user_broadcast WHERE id= $1;


-- name: DeleteProcessBroadCast :exec
DELETE FROM process_broadcast WHERE id= $1;


-- name: GetEmailsOnProcessBroadCast :one
SELECT emails from process_broadcast where 
status = $1 AND process = $2;
