0
0
React Nativemobile~10 mins

Firestore CRUD operations in React Native - Interactive Code Practice

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

Complete the code to import Firestore from Firebase in React Native.

React Native
import [1] from '@react-native-firebase/firestore';
Drag options to blanks, or click blank then click option'
Afirestore
Bdatabase
Cauth
Dstorage
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'database' instead of 'firestore'.
Confusing Firestore with Firebase Auth or Storage.
2fill in blank
medium

Complete the code to get a reference to a Firestore collection named 'users'.

React Native
const usersCollection = firestore().[1]('users');
Drag options to blanks, or click blank then click option'
Adoc
Bcollection
Cref
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'doc' which refers to a single document, not a collection.
Using 'get' which fetches data but does not return a reference.
3fill in blank
hard

Fix the error in the code to add a new document with data to the 'users' collection.

React Native
await firestore().collection('users').[1]({ name: 'Alice', age: 30 });
Drag options to blanks, or click blank then click option'
Aadd
Bget
Cupdate
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' without a document reference causes an error.
Using 'update' requires an existing document reference.
4fill in blank
hard

Fill both blanks to update the 'age' field of a user document with ID 'user123'.

React Native
await firestore().collection('users').[1]('user123').[2]({ age: 31 });
Drag options to blanks, or click blank then click option'
Adoc
Badd
Cupdate
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add' instead of 'doc' to get a document reference.
Using 'set' which replaces the whole document instead of updating.
5fill in blank
hard

Fill all three blanks to delete a document with ID 'user456' from the 'users' collection.

React Native
await firestore().[1]('users').[2]('[3]').delete();
Drag options to blanks, or click blank then click option'
Acollection
Buser456
Cdoc
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add' instead of 'doc' to get document reference.
Passing the document ID to collection instead of doc.