'Using Firebase Firestore Database User Reference [closed]
I have been reading about firestore and I am implementing it into my app.
The code that I was reading uses a realtime database and I am using cloud firestore database. The code I found is:
let userRef = Database.database().reference().child("users/profile/\(uid)")
userRef.observe(.value, with: { snapshot in
How can I get this in firestore instead of realtime databse
Thanks
Solution 1:[1]
There is no 1:1 translation of the code between the two APIs. You will have to read the documentation of both, and rewrite them yourself.
To be able to read user profiles from Cloud Firestore you must already be storing user profiles in Cloud Firestore. If you observe a node in the Firebase Realtime Database, your closure gets called with both the current data and upon any updates to that that. The equivalent in Firestore is attaching a realtime listener as shown here: https://firebase.google.com/docs/firestore/query-data/listen
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Frank van Puffelen |
