collectionToJson method
Converts a collection of Firestore Documents to a JSON object.
This function takes a list of documents and converts each one to JSON using documentToJson. It then wraps the list of document JSON objects into a collection JSON object that includes the collection path and the list of documents.
Implementation
JsonObject collectionToJson({
required String path,
List<Document> documents = const [],
}) {
final docsJson = JsonObject();
docsJson[metaName] = path;
docsJson[metaDocuments] = documents
.map(documentToJson)
.toList(growable: false);
return docsJson;
}