listDocuments method
Retrieves the list of documents in this collection.
The document references returned may include references to "missing
documents", i.e. document locations that have no document present but
which contain subcollections with documents. Attempting to read such a
document reference (e.g. via DocumentReference.get) will return a
DocumentSnapshot whose DocumentSnapshot.exists property is false
.
Implementation
Future<List<DocumentReference<T>>> listDocuments() async {
final parentPath = _queryOptions.parentPath._toQualifiedResourcePath(
firestore.app.projectId,
firestore._databaseId,
);
final response = await firestore._client.v1((client) {
return client.projects.databases.documents.list(
parentPath._formattedName,
id,
showMissing: true,
// Setting `pageSize` to an arbitrarily large value lets the backend cap
// the page size (currently to 300). Note that the backend rejects
// MAX_INT32 (b/146883794).
pageSize: math.pow(2, 16 - 1).toInt(),
mask_fieldPaths: [],
);
});
return [
for (final document
in response.documents ?? const <firestore1.Document>[])
doc(
// ignore: unnecessary_null_checks, we don't want to inadvertently obtain a new document
_QualifiedResourcePath.fromSlashSeparatedString(document.name!).id!,
),
];
}