Challenge - 5 Problems
Supabase CRUD Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ service_behavior
intermediate2:00remaining
What is the output of this Supabase insert operation?
Given the following code snippet using supabase-js, what will be the value of
data after execution?Supabase
const { data, error } = await supabase
.from('profiles')
.insert([{ id: '123', username: 'alice' }]);Attempts:
2 left
💡 Hint
Think about what supabase-js returns after a successful insert.
✗ Incorrect
When you insert data using supabase-js, the data contains an array of the inserted rows. Here, it will be an array with the inserted object.
❓ Configuration
intermediate2:00remaining
Which option correctly updates a user's email in supabase-js?
You want to update the email of the user with id 'abc123' in the 'users' table. Which code snippet correctly performs this update?
Attempts:
2 left
💡 Hint
Check the supabase-js method names for updating and filtering.
✗ Incorrect
The correct method to update rows is update() and to filter rows is eq(). Option C uses both correctly.
❓ Architecture
advanced2:00remaining
Which architecture best supports real-time updates with supabase-js?
You want your app to show live changes from the 'messages' table without refreshing. Which architecture choice best supports this with supabase-js?
Attempts:
2 left
💡 Hint
Supabase supports real-time subscriptions natively.
✗ Incorrect
Supabase-js provides real-time subscriptions to listen to database changes. This allows the app to update UI live without polling.
❓ security
advanced2:00remaining
Which option correctly restricts data access in supabase-js using Row Level Security (RLS)?
You want to ensure users can only read their own profiles from the 'profiles' table. Which setup correctly enforces this using supabase-js and RLS?
Attempts:
2 left
💡 Hint
RLS requires explicit policies to restrict access.
✗ Incorrect
Row Level Security must be enabled and a policy created to restrict access. The policy 'USING (auth.uid() = id)' ensures users only access their own rows.
✅ Best Practice
expert2:00remaining
What is the best practice to handle errors in supabase-js CRUD operations?
You perform an insert operation with supabase-js. Which approach correctly handles possible errors?
Supabase
const { data, error } = await supabase.from('tasks').insert([{ title: 'New Task' }]);Attempts:
2 left
💡 Hint
Supabase-js returns errors separately from data.
✗ Incorrect
Supabase-js returns error separately. Always check if error is present before using data to avoid unexpected issues.