0

I'm wondering how can I access to the content of a reference field. I'm learning how to use firebase. I have collections called places, users and reviews.

I did a first job getting all the reviews linked to a place document by adding a string field on each review with the id of the place related.

But I wanted to try using the reference field, so on review documents, I have a reference field called "user", containing the path (ex: users/quentin-dupuy).

But I don't succeed in accessing the content, I understand it contains only a ref, so I can't use it directly like review.data().user.data().name or something like that.

Ideally, I guess I'd need to do a getDoc with the path which is in the reference field, but I don't succeed. Also, is the reference field the right one for this kind of thing?

Floran
  • 11
  • 5
  • Document reference fields are not automatically loaded. You will need to perform a separate call to the database API to get the data for each of them. If you're struggling to make that work, edit your question to [show where you got stuck](http://stackoverflow.com/help/mcve) please. – Frank van Puffelen May 09 '23 at 23:03

0 Answers0