Introduction
Friendly Eats is a restaurant recommendation app built on Firestore. For more information about Firestore visit the docs.
Friendly Eats is a restaurant recommendation app built on Firestore. For more information about Firestore visit the docs.
Here's an adequate set of rules for running FireEats.
service cloud.firestore {
match /databases/{database}/documents {
match /restaurants/{restaurant} {
match /ratings/{rating} {
allow read: if request.auth != null;
allow write: if request.auth != null
&& request.auth.uid == request.resource.data.userId;
}
allow read: if request.auth != null;
allow create: if request.auth != null;
allow update: if request.auth != null
&& request.resource.data.name == resource.data.name
&& request.resource.data.city == resource.data.city
&& request.resource.data.price == resource.data.price
&& request.resource.data.category == resource.data.category;
}
}
}
As you use the app's filter functionality you may see warnings in logcat that look like this:
Error fetching snapshot results: Error Domain=io.grpc Code=9 "The query requires an index. You can create it here: https://console.firebase.google.com/project/testapp-5d356/database/firestore/indexes?create_index=..." UserInfo={NSLocalizedDescription=The query requires an index. You can create it here: https://console.firebase.google.com/project/testapp-5d356/database/firestore/indexes?create_index=...}
This is because indexes are required for most compound queries in Firestore. Opening the link from the error message will automatically open the index creation UI in the Firebase console with the correct parameters filled in.