-- name: GetAllUsers :many
SELECT * FROM users;

-- name: GetUserByID :one
SELECT * FROM users WHERE ID = ?;

-- name: AddUser :exec
INSERT INTO users (Username) VALUES (?);

-- name: GetUserSessions :many
SELECT * FROM user_sessions_view WHERE user_ID = ?;

-- name: AddUserSession :exec
INSERT INTO user_sessions (user_ID, session_token, created_at, valid_until, name)
VALUES (?, ?, ?, ?, ?);

-- name: GetObjectsInStorage :many
SELECT * FROM object_storage WHERE storage_location = ?;

-- name: GetUserEvents :many
SELECT * FROM event_details WHERE organizer = ?;

-- name: GetEventObjects :many
SELECT objects.* FROM objects
                          JOIN events_objects ON objects.ID = events_objects.object_ID
WHERE events_objects.event_ID = ?;

-- name: AddObject :exec
INSERT INTO objects (storagespace_ID, Name, Description, Serialnumber, created)
VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP);

-- name: CreateEvent :exec
INSERT INTO events (user_ID, Name, Description, Location, Start_Date, End_Date)
VALUES (?, ?, ?, ?, ?, ?);

-- name: GetEventCheckIns :many
SELECT * FROM check_in_log WHERE event_name = ?;

-- name: AddCheckIn :exec
INSERT INTO check_in (user_ID, checkin_event_ID, event_ID, object_ID, checkin_state_ID, datetime)
VALUES (?, ?, ?, ?, ?, ?);

-- name: GetObjectAnnotations :many
SELECT * FROM annotations WHERE object_ID = ?;

-- name: AddAnnotation :exec
INSERT INTO annotations (user_ID, object_ID, event_ID, check_in_ID, events_object_ID, text, datetime)
VALUES (?, ?, ?, ?, ?, ?, ?);

-- name: GetEventPictures :many
SELECT * FROM pictures WHERE event_ID = ?;

-- name: AddPicture :exec
INSERT INTO pictures (user_ID, storagespace_ID, object_ID, event_ID, check_in_ID, Path, Description, datetime)
VALUES (?, ?, ?, ?, ?, ?, ?, ?);
