You have a Firestore collection with 1000 documents. You run a query that returns 10 documents. How many document reads will be billed for this query?
Think about how Firestore charges for queries based on documents returned, not total documents in the collection.
Firestore charges for each document returned by a query. Since 10 documents are returned, 10 document reads are billed.
You need to update 50 documents in Firestore. Which approach reduces network calls and improves performance?
Consider how Firestore handles batched writes and network calls.
Batched writes group multiple updates into a single atomic operation, reducing network overhead and improving performance, though write costs per document remain the same.
You want to prevent users from reading documents they shouldn't access to reduce unnecessary read costs. Which security rule snippet correctly restricts reads to only documents where the user's UID matches the document's owner field?
match /documents/{docId} {
allow read: if request.auth.uid == resource.data.owner;
}Think about how to restrict access to only authorized users.
Option A allows reads only if the authenticated user's UID matches the document's owner field, preventing unauthorized reads and reducing costs.
You have a Firestore app where users frequently read profile data and their recent activity. Which data structure approach reduces read operations and costs?
Consider how denormalization can reduce the number of reads.
Denormalizing recent activity inside the user profile document allows fetching all needed data in a single read, reducing read operations and costs.
You want to minimize Firestore read costs by caching data on the client side. Which approach best balances data freshness and cost savings?
Think about how Firestore's offline persistence works and how to keep data reasonably fresh.
Firestore's offline persistence caches data locally and syncs changes automatically. Periodic manual refreshes ensure data freshness while reducing read costs.