You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
32 lines
1.2 KiB
-- name: SelectLog :one
|
|
SELECT * FROM log WHERE id=$1 OR short_id=$1 LIMIT 1;
|
|
|
|
-- name: SelectLogs :many
|
|
SELECT * FROM log
|
|
WHERE (@filter_short_id::BOOL = false OR short_id = ANY(@short_ids::TEXT[]))
|
|
AND (@filter_character_id::BOOL = false OR character_ids && (@character_ids::TEXT[]))
|
|
AND (@filter_channel_name::BOOL = false OR channel_name = ANY(@channel_names::TEXT[]))
|
|
AND (@filter_event_name::BOOL = false OR event_name = ANY(@event_names::TEXT[]))
|
|
AND (@filter_open::BOOL = false OR open = @open::BOOL)
|
|
AND (@filter_earlist_date::BOOL = false OR date >= @earliest_date::TIMESTAMP)
|
|
AND (@filter_lastest_date::BOOL = false OR date <= @latest_date::TIMESTAMP)
|
|
ORDER BY date
|
|
LIMIT NULLIF(@limit_size::INT, 0);
|
|
|
|
-- name: InsertLog :exec
|
|
INSERT INTO log (id, short_id, character_ids, date, channel_name, event_name, title, description, open)
|
|
VALUES (
|
|
@id, @short_id, @character_ids, @date, @channel_name, @event_name, @title, @description, @open
|
|
);
|
|
|
|
-- name: UpdateLog :exec
|
|
UPDATE log
|
|
SET title = @title,
|
|
event_name = @event_name,
|
|
description = @description,
|
|
open = @open,
|
|
character_ids = @character_ids
|
|
WHERE id = @id;
|
|
|
|
-- name: DeleteLog :exec
|
|
DELETE FROM log WHERE id=$1;
|