In Firebase Firestore, if you add a document to a collection without specifying an ID, what will be the result?
db.collection('users').add({name: 'Alice', age: 30});
Think about how Firestore handles document IDs when none are provided.
When you use add() without an ID, Firestore creates a unique ID automatically to avoid conflicts.
Choose the code that creates a collection named products and adds a document with ID prod123 containing a field price set to 100.
Remember that doc() with an argument sets the document ID explicitly.
Using doc('prod123') sets the document ID to prod123. Then set() adds the data.
Consider you have a collection users, each user document has a subcollection orders. How is this data organized in Firestore?
Think about how Firestore paths work for collections and documents.
Firestore stores subcollections as separate collections identified by their path under a document, not nested inside the document data.
Choose the correct Firestore security rule snippet that permits only signed-in users to add documents to the messages collection.
Check how to verify if a user is signed in using request.auth.
The condition request.auth != null ensures the user is authenticated before allowing create.
You want to design Firestore data for users and their posts. Which approach optimizes read performance and scalability?
Consider Firestore limits on document size and query efficiency.
Storing posts in a top-level collection with a userId field allows efficient queries and avoids document size limits.