You insert a new row into a Supabase table named users with columns id and name. After insertion, you run a query to count all rows in users. What will be the count if the table initially had 3 rows?
await supabase.from('users').insert([{id: 4, name: 'Anna'}]); const { data, error } = await supabase.from('users').select('*'); const count = data.length;
Think about what happens to the number of rows after adding one.
Inserting one new row increases the total count by one. Starting from 3 rows, after insertion, the count is 4.
Which option correctly inserts a row with id 5 and name 'John' into the users table using Supabase client?
Remember that insert expects an array of objects.
Supabase's insert method requires an array of objects even for a single row. Option A uses the correct syntax.
You have a large orders table with millions of rows in Supabase. You want to fetch only the latest 10 orders for a user with user_id 42. Which query is best to minimize data transfer and improve performance?
Filter first, then order and limit to reduce data scanned.
Option B filters by user_id first, then orders by date descending, and limits to 10 rows, minimizing data scanned and transferred.
You want to ensure users can only query their own data in the profiles table. Which Supabase feature helps enforce this at the database level?
Think about database-level access control.
Row Level Security (RLS) policies allow the database to restrict which rows a user can access, enforcing security at the source.
You want to insert a row into the products table but avoid errors if a row with the same id already exists. Which option correctly uses Supabase to update the existing row instead of failing?
Look for the option that updates on conflict.
Option C uses onConflict('id').merge() to update the existing row if id exists, avoiding insert errors.