findAll method

Future<FeedbackResponse<List<Map<String, dynamic>>>> findAll()

Finds all documents of the specified _collectionPath.

This method returns raw data in the form of a List<Map<String, dynamic>>. If _tryAddLocalId is true then the map will also contain a local id field based on the _idFieldName specified in the constructor so you may retrieve document id's more easily after serialization.

If you rather want to convert this data into a list of T immediately you should use the findAllWithConverter method instead. Make sure to have specified the _toJson and _fromJson methods or else the FirestoreApi will not know how to convert the data to T.

Implementation

Future<FeedbackResponse<List<Map<String, dynamic>>>> findAll() async {
  try {
    _log.info(
      message: 'Finding all documents without converter..',
      sensitiveData: _shouldNotSensitiveInfo
          ? null
          : SensitiveData(
              path: _collectionPath(),
            ),
    );
    final result = (await findCollection().get(_getOptions))
        .docs
        .map(
          (e) => e.data(),
        )
        .toList();
    _logResultLength(result);
    return _responseConfig.searchSuccessResponse(
        isPlural: result.isPlural, result: result);
  } catch (error, stackTrace) {
    _log.error(
        message: 'Unable to find all documents',
        sensitiveData: _shouldNotSensitiveError
            ? null
            : SensitiveData(
                path: _collectionPath(),
              ),
        error: error,
        stackTrace: stackTrace);
    return _responseConfig.searchFailedResponse(isPlural: true);
  }
}