I'm trying to drop a row from the Supabase databas...
# javascript
d
I'm trying to drop a row from the Supabase database. Luckily, I was doing this on my local environment because it dropped my whole table 😅
Copy code
js
rejectEntry: async function(item) {
    let index = this.items.indexOf(item);
    this.items.splice(index, 1);
    const deleteEntry = await supabase
      .from('submissions')
      .delete()
      .match(item.id)
    if (deleteEntry.error) throw deleteEntry.error;
  },
Can anyone suggest what was wrong? I assumed that .match would match the item ID from the table and remove that.
s
If you are using match you need to pass it an object like
.match({ id: item.id })
m
That makes me think: shouldn't supabase-js do a small validation on match specially when working with delete and update? Even though I doubt in a well designed application a whole table would be deleted due to the policies
s
The dynamic nature of JavaScript itself wouldn't help much with this, it would mean Supabase library would have to be checking if the property of
.match
is an object and if that object has both key and values, which seems like an overkill for something that is already documented. I think you can potentially get some of these benefits if you are using TypeScript as it should know the object shape that match requires