简体   繁体   中英

How to get all documents at once for a set of doc IDs, but only part of the properties in those docs, not the entire docs, in Firestore?

How to get all documents at once for a set of doc IDs, but only part of the properties in those docs, not the entire docs?

This works to get all the docs at once:

const refs = selection.map(id => db.doc(`CollectionName/${id}`))
const request = await db.getAll(...refs)

So I tried this to retrieve only a few properties, but it does not work:

const refs = selection.map(id => db.doc(`CollectionName/${id}`).select("property1","property2"))
const request = await db.getAll(...refs)

As far as I can tell there is no way to get only specific fields for a list of document references. Calling getAll with a list of document references returns the full snapshots of those documents, and calling select to get a subset of the fields is only possible on a Query which you can't initialize with a set of document references.

I don't think this is an inherent limitation of the product though, so it might be worth it to file a feature request .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM