Commit a11f4199 authored by Mahmoud Aglan's avatar Mahmoud Aglan

feat: add upsert method to SupabaseClient for arena seekers

Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent ddc21a8a
......@@ -64,6 +64,21 @@ class SupabaseClient {
return $this->request('DELETE', $url);
}
public function upsert(string $table, array $data, string $onConflict = ''): array {
$url = $this->baseUrl . '/' . $table;
$headers = $this->headers();
$headers = array_map(function($h) use ($onConflict) {
if (str_starts_with($h, 'Prefer:')) {
return 'Prefer: return=representation,resolution=merge-duplicates';
}
return $h;
}, $headers);
if ($onConflict) {
$url .= '?on_conflict=' . $onConflict;
}
return $this->request('POST', $url, $data, $headers);
}
public function rpc(string $fn, array $data = []): array {
$url = $this->baseUrl . '/rpc/' . $fn;
return $this->request('POST', $url, $data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment