|
|
@ -10,7 +10,7 @@ module Invidious::Database::Channels
|
|
|
|
# Insert / delete
|
|
|
|
# Insert / delete
|
|
|
|
# -------------------
|
|
|
|
# -------------------
|
|
|
|
|
|
|
|
|
|
|
|
def insert(channel : InvidiousChannel)
|
|
|
|
def insert(channel : InvidiousChannel, update_on_conflict : Bool = false)
|
|
|
|
channel_array = channel.to_a
|
|
|
|
channel_array = channel.to_a
|
|
|
|
|
|
|
|
|
|
|
|
request = <<-SQL
|
|
|
|
request = <<-SQL
|
|
|
@ -18,6 +18,13 @@ module Invidious::Database::Channels
|
|
|
|
VALUES (#{arg_array(channel_array)})
|
|
|
|
VALUES (#{arg_array(channel_array)})
|
|
|
|
SQL
|
|
|
|
SQL
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if update_on_conflict
|
|
|
|
|
|
|
|
request += <<-SQL
|
|
|
|
|
|
|
|
ON CONFLICT (id) DO UPDATE
|
|
|
|
|
|
|
|
SET author = $2, updated = $3
|
|
|
|
|
|
|
|
SQL
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
PG_DB.exec(request, args: channel_array)
|
|
|
|
PG_DB.exec(request, args: channel_array)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|