How to push new data from Realtime Database to Cloud Firestore? - firebase

I am pushing data to Firebase via Zapier and it lands in the Realtime Database. However, I am using Cloud Firestore. I've looked through a lot of documentation for both services but neither seems to have answers.. (there is information on migrating but I would like to keep both DBs).
How would I push each new or updated data entry from Realtime Database to Cloud Firestore?

There is nothing built into Firebase to automatically do this.
The fastest I can think of is to build a Cloud Function that listens for the Realtime Database writes, and then also sends them to Firestore.
Alternatively, doesn't Zapier allow you to have two zaps, one that writes to each database?

Related

What is the standard way to store images and data with Firebase?

We need to store user data on a database. We also need to store content/info data and images to be dynamically served to the users via a PWA.
When I tried creating the Firestore DB for the users, Firebase warned me:
"Enabling Cloud Firestore will prevent you from using Cloud Datastore with this project, notably from the associated App Engine app"
If this means that we cannot use Firestore and Storage together, what is the standard way to have a database and image content to be served to the users, with Firebase?
Cloud Datastore is not Cloud Storage. They are different Google Cloud products. If you enable Firestore, you will still be able to use Storage just fine.

How to perform transaction which includes both firebase real-time database and firestore?

I'm using firebase Realtime Database and Firestore for my project. We can perform batch operations on firebase Realtime Database using updateChildren() and commit() on Firestore. But I have to perform a batch operation which includes some parts of Realtime Database and some part of Firestore. Is there any way I can do that?
There is no way to run a single transaction across both Cloud Firestore and the Realtime Database.
You'll have to find a way to write the data in two separate transactions, and make sure your code that reads the data is robust enough to handle the case where one transaction has completed while the other hasn't.

Firebase Realtime Database to Cloud Firestore

I´m searching the best way to migrate Firebase Realtime Database Data to Cloud Firestore for a json database with many nested rows. Example:
I found nothing that could help me. For what I need the migration is the new offline functionality of the Cloud Firestore. I´m using Ionic3 (Angular5)
Actually there's no standard way to migrate from Firebase Realtime Database to Cloud Firestore, because every application or project has is unique. You have to implement your own way of migrating to Cloud Firestore. But I suggest you read the next tutorials that will help you find the best way for you to migrate:
Cloud Firestore Data Model.
Firestore Data Structure.
Important note: By the way Firebase Realtime Database supports offilne persistence: Enabling Offline Capabilities Realtime Database.

The data on Apple watch send to firebase

I want to send the acceleration data which is retrieved from Apple Watch to Cloud Storage for Firebase.
However, Firebase is not support watchOS.
Should I have sent the acceleration data to the storage via iPhone?
Please teach me a better method.
As a workaround you could send the data to the Firebase Realtime Database or Cloud Firestore using the REST Service. By implementing a Firebase node.js cloud function which triggers on Data Writes you could copy the data to Cloud Storage.
Anyway for your purpose it seems to be a better solution to work with the super fast Realtime Database instead of the slow storage.

.info/serverTimeOffset for Firestore?

I am using Firebase Firestore and want to get a rough idea of the the server time. Similar to how the Realtime Database had .info/serverTimeOffset. I could create a realtime database just to use the .info/serverTimeOffset endpoint but is there any better way using just Firestore?
There is no equivalent of .info/serverTimeOffset in Cloud Firestore at the moment. That's one of the reasons we recommend using the Firebase Realtime Database for a presence system, even when you use Cloud Firestore for other data storage needs.

Resources