0

I have a function that gets all the documents where an id matches like so:

const query = admin.firestore().collection('unassignedItems').doc('1uD82gAXORYsyimX5Dw23DDAimx1').collection('unassigned')
    .where('meta.designId', "==", id);

const qs = await query.get();
const items = [];

qs.forEach(doc => {
    items.push(doc.data());
});
return items;

The documents that are returned though all have a subCollection called images, that contains a document containing more information.

Is there a way I can return this information along with the parent document information at the same time from my function?

K20GH
  • 6,032
  • 20
  • 78
  • 118

1 Answers1

1

Since Cloud Firestore queries are shallow and don't touch subcollections, you will need to query each subcollection individually, in addition to the query you're making for the documents in unassignedItems/{id}/unassigned.

See also:

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441