0

I am using a firebase cloudstore. I know that there are no joins available. But I can't even find a way to query data efficiently by making two separate queries.

I have two collections

  • users

    • fullname
    • avatar
  • posts

    • text
    • postOwner (userId)

I want to query for posts get all users ids and then query users collection for additional information. But it seems that there is no way to load data in bulk given list of ids. (react-native-firebase)

  1. How can I do that?
  2. Do you think this data model well structured? Any alternatives?

If there is no way please recommend a workaround.

Wild Goat
  • 3,509
  • 12
  • 46
  • 87
  • There is no Firestore equivalent of a SQL `SELECT * FROM Users WHERE id IN (1,2,3)` in the client-side SDKs. You will need to load them individually, but this is not nearly as slow as you may think (for reasonable numbers of documents for handling in a client-side app). This has been asked before, so have a look at https://stackoverflow.com/q/46721517, – Frank van Puffelen Jun 07 '19 at 17:48
  • @FrankvanPuffelen Ok, I didn't try if it will cause a performance issue, I will give it a go. However, we will pay more for reading data N times. I will give it a go anyway. Thanks – Wild Goat Jun 07 '19 at 18:25
  • On reading Firestore charging per document that is read. It doesn't matter if you read them individually, or through a query, the charges are the same. – Frank van Puffelen Jun 07 '19 at 18:56

0 Answers0