Is it possible to reset, and recreate firestore? - firebase

I'm trying to migrate my firestore database to a new location, since google added a new Canadian region after we created our database in US-West.
The standard answer is you can't change the location of firestore after creating it. The only way
I've heard is possible is to create a completely new project. Obviously that has many down-sides.
However, I was wondering if its possible to reset and recreate firestore in the desired region within the original project as a work-around? That way I wouldn't need to create a new project.
The steps would be as follows:
Export firestore data to google cloud storage
Move exported data to a new storage bucket in the desired region (You can't run firestore import across regions)
Reset firestore
Recreate firestore in the desired region
Import the exported data into firestore

For now it is not possible to change the region for a Firestore instance already created as mentioned in the docs and you may need to migrate all the data to the new project.
Anyway there is already a Feature Request so the location can be changed at any time in the same project

Related

How to add my project to multiple GCP resource locations?

I have built a firebase project which has "asia-south1" as its default GCP location, I choose this location because other servers had too much latency. But now I want the application to work in other countries as well, The data of one GCP location will also be accessed by others if we have multiple firebase projects and now I have really no idea how to proceed, your help would be really appreciated.
Hope I was able to clear the question
Thank you
Your Cloud Firestore data can be kept in either a regional or a multi-regional location. The developer must choose a location when Firestore is enabled in a project.
The only way for a developer to alter the location of data in an existing project is to start a new Firestore project at the desired location and transfer the data using the Import/Export capability. A Firestore project's location is not currently possible to be changed.
This is the public documentation on Firestore locations.
Just to clarify and complete my current response a little more, the only way to migrate your data (move your data) to another project at this time is manually using the managed export feature, as stated in this official document, or using cloud functions to schedule exports, as stated in this other one document, and then importing the data into your destination project.
It is unfortunately impossible to change the location of Firestore resource locations after setting up Functions, RTDB or Firestore. As per The Docs, Warning: Setting the location for one of these services (that is, Cloud Firestore, Cloud Storage, or scheduled functions) also sets the location for the others. After you set your project's default GCP resource location, you cannot change it.

How to get fetch data from firestore as a map in flutter?

I'm a newbie trying to make a blog view for my application and for that I want to fetch all the links saved as string in cloud firestore. It would be nice if I could get the values as string or if I could get a complete map and then reference the value to get data.
How do I do that?
Here's an example:
https://i.stack.imgur.com/DDo4d.png
As you can see I want to fetch the https links as string in my flutter project.
And I should be able to add more https links in the future in my cloud firestore, and the application should update itself. How do I do that?

Is it possible change the default Firebase Realtime Database?

Is it possible to change the default Firebase Realtime database for an existing Firebase project in any way?
The CLI commands doesn't have this option neither does the web console.
Is it possible somehow to change the default Firebase Realtime database?
Is it possible to change the default Firebase Realtime database for an existing Firebase project in any way?
No, there is not. You cannot change the default location once it was created.
It's possible to create a new database with an alternative location?
Yes, it is possible. You can create a new instance of the Realtime Database that can be located in a totally different location than the others. According to the official documentation of the Realtime Database locations:
If you create a new Realtime Database instance, you're prompted to select the location of the instance in the Firebase console workflow. Each Realtime Database instance in your project can be located in a different location. The currently supported locations for Realtime Database instances are listed below along with their associated database URL schemes.
There isn't any way to change the default realtime database instance as far as I know. You cannot even delete the default instance (it can be disabled though). If you are trying to set another instance as default, you can just export the data as JSON and then import it in the default database instance.

Find n nearest locations in flutter: local database (Sqlite) in combination with Cloud Firestore vs Firebase Realtime Database

I am working on the following topic right now:
about 8000 stores/objects(uniqueID, name, adress, latitude, longitude, geohash, amount of productX, amount of productY.)
in the future there will be new stores and also some of the stores will be deleted
I am planning to add a version attribute to each data: for example I start with version1. If I receive an update or a new store then it will have version2
it is not needed to receive realtime changes. This data will be changed only a couple of times each month
Flutter app with a feature: find n stores at this location
because the data is not changed frequently I was planning to put an updated local sqlite database to each build
I will use Realtime Database or Firestore to receive updated data within my app to avoid to publish a new version only because database was changed
Firestore: I will add only a new attribute to my document and I will request all data that is newer than my local database version and I will also have a collection that has all deleted items
Realtime database: here I would have something like this
-updates
version1
newData: List of unique IDs
deletedData: List of unique IDs
I read a lot about geo queries on firestore and I also found a working flutter plugin to do this filtering on serverside, but because my data is not changed that frequently I am very confused about the best approach.
Questions:
Is my approach a good idea or should I forget about the local sqlite DB and use only Firebase/Firestore?
If I will use the local database and will only observe updates from the backend, which of the services should I use in terms of pricing etc.? (Advantage Firestore: If I use Firestore I can easily switch to it by using the flutter plugin and forget about my local database)
If you have only a couple of thousand objects, and the data hardly every changes, I'd typically consider querying the data locally on the device. You can likely very quickly iterate over the 8,000 items to check their lat/lon against the user location.
You could then use something like Firebase Storage or even Firebase Hosting to distribute updated data sets to the users. Of course you could use Firestore or Realtime Database for that too, but if you're not using their querying or realtime capabilities, there are cheaper options to distribute a static file.

What's the best way to store static data in firebase

I'm writing firebase android app in android studio. I have almost 2000 geo locations and I want them to be marked on map all the time. Firebase databse isn't good idea to store such data because this is static data. So firebase storage, hosting, just some list in code or something different would be the best way?
Thanks in advance
For static data, you could use list and append all the geo locations with push() method. The push() method generates a unique key every time a new child is added to the specified Firebase reference.
By using these auto-generated keys for each new element in the list, several clients can add children to the same location at the same time without write conflicts. The unique key generated by push() is based on a timestamp, so list items are automatically ordered chronologically.
For static data that you create yourself, I'd use Firebase Hosting. It gives you a simple way to update the data with firebase deploy, and comes with a built-in CDN.
For unstructured data that your users create, use Cloud Storage for Firebase.
For structured data that your users create, use Cloud Firestore or the Realtime Database.
Also see: Firebase : Differences between realtime database and file storage

Resources