1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

supabaseのmatchはオブジェクト

1
Last updated at Posted at 2026-06-08

はじめに

Supabaseを使ってDB処理を実装する中で、.match() の使い方につまずいたので、その内容を共有します。

内容

// 削除
export const deleteRecords = async (id) => {
  await supabase.from("study-record").delete().match(id);
};

上記のコードで削除実行すると、400エラーが出現。
400エラーは、ブラウザから送信されたリクエストに誤りや不備があるため、サーバーが処理を拒否しているようです。

原因

.match() は { カラム名: 値 } のように、条件をオブジェクト形式で渡す必要があります。
しかし、最初は id の値だけを渡していたため、どのカラムに対する条件なのかを Supabase 側が判断できない状態になっていました。

解決

// 削除
export const deleteRecords = async (id) => {
  await supabase.from("study-record").delete().match({ id });
};

オブジェクトにしたら無事に削除できました。

最後に

無事に解決できましたが、ちょっと時間がかかりました。
困った時は公式を見る癖をつけないとですね。

参考

ありがとうございます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?