invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.64k stars 2.21k forks source link

Firestore DocumentSnapshot doesn't support DocumentReference types #468

Closed devboy closed 6 years ago

devboy commented 6 years ago

Issue

A document containing a field of type reference is null in data()!

users.docs[1].data() // {nickname: "ivan", friend: null}

Environment

  1. Application Target Platform: iOS

  2. Development Operating System: macOS

  3. Build Tools: XCode 9

  4. React Native version: 0.49.1

  5. RNFirebase Version: 3.0.0

  6. Firebase Module: Firestore

chrisbianca commented 6 years ago

@devboy Thanks for flagging this, we must have missed reference data types with our initial implementation.

Have you got an example of how you created the document with a reference in the first instance? It will really help us make sure we implement it correctly and add some tests.

devboy commented 6 years ago

@chrisbianca I actually created it via the Firestore UI.

chrisbianca commented 6 years ago

Ah ok. Out of interest, what would you expect it to be once the library has loaded the data? A string? It's not clear from the Firestore docs what their expectation is

devboy commented 6 years ago

Good question. What does the web-sdk return? My expectation was for the data to be joined together...

devboy commented 6 years ago

I just checked, and the web-sdk does return a DocumentReference screen shot 2017-10-06 at 13 55 29

chrisbianca commented 6 years ago

Thanks for confirming! We'll have a think and try and add support for this as soon as we can

devboy commented 6 years ago

Thanks @chrisbianca

priyankinfinnov commented 6 years ago

+1

Also, unable to save DocumentReferences to the database.

I tried 2 things as mentioned at https://firebase.google.com/docs/firestore/data-model#references

//first
var userref = Firebase.firestore().doc('users/1234');
//second
var userref = Firebase.firestore().collection('users').doc('1234')

//common code to user reference and save in other document
Firebase.firestore()
      .collection('users')
      .doc('9876')
      .set({
          'friends':{
                '1234': userref
          }
      })
      .then(() => {
        //Success
      })
chrisbianca commented 6 years ago

@psycura I've just pushed up support for DocumentReference, Dates, GeoPoints, etc. It would be great if you could test with the latest version of the code and let me know if there are any issues before we release over the next few days.

You can install by doing the following:

npm install --save https://github.com/invertase/react-native-firebase.git

Please re-open if there are still issues with DocumentReference, or you find something else isn't working.

chrisbianca commented 6 years ago

This is now live as part of the v3.0.3 release

PatronGGBot commented 6 years ago

Awesome. Thanks for your work!

cjam commented 6 years ago

Just ran into this and I updated. I can confirm this is working in v3.0.3, thanks for fixing this guys!