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.
Related
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?
Both in Firestore security rules and Firebase realtime db rules it is possible to make assessments on a pre-existing document in a specific location:
Firestore example : get(/databases/$(database)/collection/mydoc).data
Firebase example : root.child('collection').child('mydoc').val()
My question is:
is it possible to cross reference these rules from Firestore to Realtime db? i.e. validate the presence of a Firestore document from a Firebase rule and/or vice versa, possibly avoiding cloud functions?
Is it possible to cross reference these (security) rules from Firestore to
Realtime db?
No, it is not possible to "cross-reference" the different Security Rules between services.
Note that it is the same with Cloud Storage and Firestore or Cloud Storage and the RTDB.
As you said you may use a Cloud Function for that and there are several approaches here:
Use a Cloud Function to read and write data to e.g. Firestore, and in the Cloud Function check the existence of the node in the RTDB. Writing to/reading from a DB through a Cloud Function may have some drawbacks, see this article.
Use a Cloud Function to mirror the two database structures, e.g. create a new Firestore doc in the collection collection when a new RTDB node is created at the child('collection').child('mydoc') location. With this second approach you can still use security rules and the client SDKs when writing to and reading from Firestore.
(same logic apply if you invert the databases in the examples above)
I am currently using Firebase Realtime database. I have imported JSONs into Realtime database but due to limitation of query i need to switch on Firebase Firestore.
I want to import JSONs into Cloud Firestore of Firebase.
There is no automatic conversion from Firebase's Realtime Database to Cloud Firestore. While both are NoSQL databases and part of Firebase, their data models are different, and they are not compatible in any way.
You will have to figure out how you want to map your JSON data from Realtime Database, to the collection/document model of Cloud Firestore, and then write code against the APIs of the databases to port the data over.
Also see:
Migrate Firebase Realtime Database to Firestore
Converting Firebase Database to Cloud Firestore
Firebase Realtime Database to Cloud Firestore
Blog post: Migrating from Firebase Realtime Database To Firestore — pricing and limits
Blog post: Survival guide: how to migrate from the Firebase Realtime Database to Cloud 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.
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.