mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-17 18:38:50 +00:00
Move DB queries related to 'annotations' in a separate module
This commit is contained in:
24
src/invidious/database/annotations.cr
Normal file
24
src/invidious/database/annotations.cr
Normal file
@@ -0,0 +1,24 @@
|
||||
require "./base.cr"
|
||||
|
||||
module Invidious::Database::Annotations
|
||||
extend self
|
||||
|
||||
def insert(id : String, annotations : String)
|
||||
request = <<-SQL
|
||||
INSERT INTO annotations
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT DO NOTHING
|
||||
SQL
|
||||
|
||||
PG_DB.exec(request, id, annotations)
|
||||
end
|
||||
|
||||
def select(id : String) : Annotation?
|
||||
request = <<-SQL
|
||||
SELECT * FROM annotations
|
||||
WHERE id = $1
|
||||
SQL
|
||||
|
||||
return PG_DB.query_one?(request, id, as: Annotation)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user