Home > Mobile >  How to get all documents at once for a set of doc IDs, but only part of the properties in those docs
How to get all documents at once for a set of doc IDs, but only part of the properties in those docs

Time:12-01

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)

CodePudding user response:

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.

  • Related