Skip to content

Conversation

@imsamgarg
Copy link

now support firestore documents with custom converter

before documents initiated with withConverter collection couldn't be passed into function because
function takes DocumentReference<Map<String,dynamic>> type but our doc is DocumentReference type

error befor---
`
final doc=i.collection("col").withConverter(fromFirestore: fromFirestore, toFirestore: toFirestore).doc("doc");

`

@imsamgarg imsamgarg changed the title withConverter_fix fix: withConverter May 18, 2022
@codecov
Copy link

codecov bot commented May 19, 2022

Codecov Report

Merging #99 (4404ff1) into main (e13e3a8) will decrease coverage by 13.15%.
The diff coverage is 64.28%.

@@             Coverage Diff              @@
##              main      #99       +/-   ##
============================================
- Coverage   100.00%   86.84%   -13.16%     
============================================
  Files            1        1               
  Lines           31       38        +7     
============================================
+ Hits            31       33        +2     
- Misses           0        5        +5     
Impacted Files Coverage Δ
lib/src/firestore_cache.dart 86.84% <64.28%> (-13.16%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e13e3a8...4404ff1. Read the comment docs.

Copy link
Owner

@zeshuaro zeshuaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this PR. Would you be able to address these comments?

/// pass toFirestore method to converter
static Future<QuerySnapshot<T>> getDocuments<T>({
required Query<T> query,
required DocumentReference<T> cacheDocRef,
Copy link
Owner

@zeshuaro zeshuaro May 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can understand the use case for Query<T> then returning QuerySnapshot<T>. But can people simply pass in the default Map<String, dynamic> for cacheDocRef? For the example code you shared, can you pass in FirebaseFirestore.instance.doc('col/doc') instead? This document is simply used for fetching the cache date info, so I would imagine there's no need to use the parameter with the converters.

Also, I don't think it can use the same type T which is used for Query and the returned QuerySnapshot>, as it probably has a different type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants