-- name: CreateExitPointRoaster :one
INSERT INTO exitpointroaster (
     status,
     user_id,
     date,
     exitpoint_id,
     dayshift,    
     nightshift
 ) VALUES (
    $1, 
    $2,
    $3,
    $4,
    $5,
    $6
 ) RETURNING *;


-- name: CreateRoasterCount :one
INSERT INTO roastercount (
     user_id,
     counter
 ) VALUES (
    $1, 
    $2
 ) RETURNING *;

-- name: UpdateRoasterCount :one
UPDATE roastercount 
    SET
      counter = counter + 1
WHERE user_id = $1
RETURNING *;

-- name: CheckIDExistanceInRoaster :one
SELECT EXISTS(
   SELECT 1 FROM roastercount
   WHERE  user_id = $1
);


-- name: RoasterExitPointID :one
SELECT exitpoint_id
FROM exitpointroaster
WHERE date  = $1 
AND user_id = $2
LIMIT 1;

-- name: RoasterExitPointWeek :many
SELECT exitpointroaster.status,exitpointroaster.user_id,
exitpointroaster.date,exitpointroaster.exitpoint_id,exitpoints.expdescription,
exitpoints.expcode,users.fullname,exitpointroaster.dayshift,exitpointroaster.nightshift 
FROM exitpointroaster
JOIN users on users.id = exitpointroaster.user_id
JOIN exitpoints on exitpoints.id = exitpointroaster.exitpoint_id; 