Google Firestore - how to get document by multiple ids in one round trip?

前端 未结 11 2065
余生分开走
余生分开走 2020-11-21 22:49

I am wondering if it\'s possible to get multiple documents by list of ids in one round trip (network call) to the Firestore.

11条回答
  •  清歌不尽
    2020-11-21 23:32

    The best you can do is not use Promise.all as your client then must wait for .all the reads before proceeding.

    Iterate the reads and let them resolve independently. On the client side, this probably boils down to the UI having several progress loader images resolve to values independently. However, this is better than freezing the whole client until .all the reads resolve.

    Therefore, dump all the synchronous results to the view immediately, then let the asynchronous results come in as they resolve, individually. This may seem like petty distinction, but if your client has poor Internet connectivity (like I currently have at this coffee shop), freezing the whole client experience for several seconds will likely result in a 'this app sucks' experience.

提交回复
热议问题