0
0
Firebasecloud~10 mins

Batch writes in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a batch write instance.

Firebase
const batch = [1](db);
Drag options to blanks, or click blank then click option'
AbatchWrite
BwriteBatch
Cbatch
DcreateBatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'batchWrite()' instead of 'writeBatch()'.
Trying to call 'batch()' directly on the database.
2fill in blank
medium

Complete the code to add a set operation to the batch.

Firebase
batch.[1](docRef, { name: 'Alice' });
Drag options to blanks, or click blank then click option'
Awrite
Badd
Cupdate
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add()' which is for collections, not batch writes.
Using 'update()' which requires the document to exist.
3fill in blank
hard

Fix the error in the code to commit the batch.

Firebase
await batch.[1]();
Drag options to blanks, or click blank then click option'
Acommit
Brun
CcommitBatch
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'execute()' which does not exist on batch.
Using 'commitBatch()' which is not a method.
4fill in blank
hard

Fill both blanks to add a delete operation and then commit the batch.

Firebase
batch.[1](docRef);
await batch.[2]();
Drag options to blanks, or click blank then click option'
Adelete
Bcommit
Cremove
Dexecute
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'remove()' which is not a batch method.
Using 'execute()' instead of 'commit()'.
5fill in blank
hard

Fill all three blanks to update a document, add a set operation, and commit the batch.

Firebase
batch.[1](docRef, { age: 30 });
batch.[2](docRef2, { name: 'Bob' });
await batch.[3]();
Drag options to blanks, or click blank then click option'
Aupdate
Bset
Ccommit
Dwrite
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'write()' which is not a batch method.
Mixing up 'set()' and 'update()' methods.