0

I have two collections in firestore: users and reports.

  • Users

    • uid ( this uid is from firebase auth, required field )
    • email ( this is not required field, as i am using social media auth )
    • firstname
    • last name
  • Reports

    • uid (this uid is from firebase auth, required field, added when user add this report)
    • isCompleted ( bollean )
    • other fields

I want to get all reports, firstname and lastname of users who isCompleted is false.


Query

firebase
    .firestore()
    .collection("reports")
    .where("isCompleted", "==", false)
    .get()
    .then()
    .catch()

Problem

Using this query i can get all reports whoes isCompleted is false but how can i get firstname and lastname of user who has created this report using uid

Ferin Patel
  • 3,424
  • 2
  • 17
  • 49
  • @MauriceNino This loads all users, not just the ones who authored the last 3 posts. While this may work fine during development, as you add more users you will be loading more and more unnecessary data. This issue remains the same from accepted answer. – Ferin Patel Jul 20 '20 at 11:21
  • Generally speaking, firestore is optimized for reads not for writes, so the easiest and recommended way to solve this, is to just save the user data to the report. I don't know if there is any kind of useful join query with firestore. I don't really think so, as it is also not an option to load partial documents. – MauriceNino Jul 20 '20 at 11:39

0 Answers0