Choosing Firestore Collections that need to be synced [duplicate] - firebase

This question already has answers here:
With firestore, is it possible to configure offline persistence to set 'off' in a specific document?
(2 answers)
Closed 3 years ago.
I am unable to find details of how Firebase Firestore chooses what to cache locally. The documentation is vague about this. It says that Firestore caches data that the app is actively using.
My requirement is that I need to explicitly set specific collections to be cached locally on the device. Is it possible to do it with Firestore?

My requirement is that I need to explicitly set specific collections to be cached locally on the device.
There is no way you can specify which collection may exist in cache and which not. By default, Firestore caches all data that your application reads. It's all or nothing.
Is it possible to do it with Firestore?
No, it's not.

Related

Firebase security rules for public read without authentication [duplicate]

This question already has answers here:
Firestore Security rules without Authentification
(3 answers)
Firestore security rules without auth
(1 answer)
How do we secure a Firebase Firestore without using Firestore Authentication? Or is it a must?
(1 answer)
Closed 3 days ago.
I have made an app which show pdf files and some data which are store in firestore database. And no need to signup or login to read the data through app. But I am getting mail from firebase to update security rules and I have no ideas about firebase security rules.
Can you suggest me the secure rules for firestore database so that user can able to read the data but can't allow to perform write operation.
You should first read the documentation on security rules. There is plenty of information out there to use as a guide, especially the basic rules.
You will have to give read access to each collection individually in order to avoid getting the warning email. Taking the pattern from the linked documentation, if the collection you want to give access is named "cities":
match /cities/{city} {
allow read;
}
Since we don't know the names of your collections, we can't tell you exactly what to do.

how to detect the device connectivity state while using firebase? [duplicate]

This question already has answers here:
Check whether there is an Internet connection available on Flutter app
(27 answers)
Closed 2 years ago.
I'm using flutter with firebase, how can I know if my device is connected to the internet or not when I wanna make a query to firestore? if my device is offline what will firestore return ?, I must detect the device connectivity situation, so I can emit a certain state in my app.
The Firestore SDK doesn't provide any way to know if the app is offline. The SDK was designed to work while offline. So, if you perform a query while offline, you will either get cached results, or the query will silently retry in the background.
If you want to test for connectivity, you will need try another method to do that. Or, you could use the Firestore REST API (not the Flutter SDK) and detect if the query failed due to network problems.

What prevents clients from taking advantage of your Firebase apiKey in the client code? [duplicate]

This question already has answers here:
Is it safe to expose Firebase apiKey to the public?
(10 answers)
Should I hide firebase api keys into backend? Not due to data security but project cloning issue
(2 answers)
Closed 2 years ago.
I have been messing around with Firebase in a web app and realized there's something I don't understand.
In order for the JS code to send data to the Firebase servers, your apiKey has to be in the JS. But then that means your API key is public, and anyone using your website can inspect the code and just send arbitrary commands to Firebase on your behalf from the dev tools, or from any other site now that they have the API key.
I know I must be missing something, since this would make Firebase not useful. What is it I'm missing? What prevents users from sending arbitrary commands to Firebase with your ApiKey?

Realtime Database vs Firestore [duplicate]

This question already has answers here:
What's the difference between Cloud Firestore and the Firebase Realtime Database?
(5 answers)
Closed 3 years ago.
I am building an app related to online bookings of Barbers in my city.I am planning to use Firebase to store my data and showing realtime updates. What will be the right option i.e. Realtime Database or Firestore. As much as I read, Firestore is great but it costs the developers according to number of queries and in my case query numbers will be much higher as I am planning to show realtime update to clients for their booking status.
And I am a naive in this area so suggest which one will be easy to learn.
It's up to you in the end, so I'll just name some main points:
Realtime Database is basically one giant JSON file, while Cloud Firestore is based on collections of documents.
Both offer realtime updating.
Cloud Firestore has better ways to filter and sort data.
Cloud Firestore has more advanced ways of writing and updating information.
Realtime Database is based on a single region, while Cloud Firestore can scale to multiple regions automatically.
They have different security options.
Realtime Database charges based on bandwidth and storage, but at a higher rate. As you mentioned in your question, Cloud Firestore charges based on operations on your database (read, write, etc.)
In the end, it all depends on how you want to work in your code. For example, do you want to work with one large JSON tree, or do you want to work with separate documents? Cloud Firestore is the newer of the two, but that doesn't necessarily mean it's better in your scenario.

How to use Datastore instead of Firestore? [duplicate]

This question already has an answer here:
Revert from Google Cloud Firestore to Datastore
(1 answer)
Closed 4 years ago.
I have used Firestore before, but since there is a "Beta limits" right now, I want to use Datastore instead of Firestore.
And here is the problem... When I open Datastore in the Google Cloud console, I see this message. Even when I tried to disable Firestore API, it still shows up. Is there any way to use Datastore after creating a Firebase project?
It seems revert from Google Firestore to Datastore is not possible without deleting project or creating a new one.
See this answer by Product Manager at Google.

Resources