10 lines
250 B
PL/PgSQL
10 lines
250 B
PL/PgSQL
-- RPC to atomically increment plays_count
|
|
CREATE OR REPLACE FUNCTION increment_plays(podcast_id uuid)
|
|
RETURNS void AS $$
|
|
BEGIN
|
|
UPDATE podcasts
|
|
SET plays_count = plays_count + 1
|
|
WHERE id = podcast_id;
|
|
END;
|
|
$$ LANGUAGE plpgsql SECURITY DEFINER;
|