C. The method where does not exist; should use eq instead
D. The table name 'users' is invalid
Solution
Step 1: Check method chaining for update filters
supabase-js uses eq() to filter rows, not where().
Step 2: Confirm other parts
Updating numeric fields is allowed, select() is optional, and 'users' is a valid table name.
Final Answer:
The method where does not exist; should use eq instead -> Option C
Quick Check:
Use eq() not where() for filtering [OK]
Hint: Use eq() to filter, not where() [OK]
Common Mistakes:
Using where() instead of eq()
Thinking update() needs select() always
Assuming numeric fields can't be updated
5. You want to delete all rows from the orders table where the status is 'cancelled'. Which code snippet correctly performs this action and handles errors?
hard
A. const { error } = await supabase.from('orders').delete().eq('status', 'cancelled'); if (error) console.error(error);
B. const { data } = await supabase.from('orders').remove().eq('status', 'cancelled'); if (data) console.log(data);
C. const { error } = await supabase.from('orders').delete('status', 'cancelled'); if (error) console.error(error);
D. const { error } = await supabase.from('orders').delete().where('status', 'cancelled'); if (error) console.error(error);
Solution
Step 1: Identify correct delete syntax with filter
supabase-js uses delete() followed by eq('column', value) to filter rows to delete.
Step 2: Check error handling
The code checks if error exists and logs it, which is best practice.
Final Answer:
const { error } = await supabase.from('orders').delete().eq('status', 'cancelled'); if (error) console.error(error); -> Option A
Quick Check:
delete() + eq() + error check = correct [OK]
Hint: Use delete().eq() and check error for safe deletion [OK]
Common Mistakes:
Using remove() instead of delete()
Using where() instead of eq()
Not handling errors after delete
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.