Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for applying default converter in withConverter() #1394

Merged
merged 5 commits into from
Jan 25, 2021

Conversation

thebrianchen
Copy link

No description provided.

@thebrianchen thebrianchen self-assigned this Jan 24, 2021
@thebrianchen thebrianchen requested review from a team as code owners January 24, 2021 00:20
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jan 24, 2021
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Jan 24, 2021
@codecov
Copy link

codecov bot commented Jan 24, 2021

Codecov Report

Merging #1394 (8744b9c) into master (eb1b4dc) will increase coverage by 0.22%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1394      +/-   ##
==========================================
+ Coverage   98.28%   98.51%   +0.22%     
==========================================
  Files          32       32              
  Lines       19341    19374      +33     
  Branches     1308     1273      -35     
==========================================
+ Hits        19010    19086      +76     
+ Misses        321      284      -37     
+ Partials       10        4       -6     
Impacted Files Coverage Δ
dev/src/collection-group.ts 95.33% <81.81%> (+0.20%) ⬆️
dev/src/bulk-writer.ts 100.00% <100.00%> (+0.46%) ⬆️
dev/src/reference.ts 99.89% <100.00%> (+0.11%) ⬆️
dev/src/index.ts 97.56% <0.00%> (+0.12%) ⬆️
dev/src/watch.ts 99.06% <0.00%> (+0.23%) ⬆️
dev/src/validate.ts 98.29% <0.00%> (+0.24%) ⬆️
dev/src/transaction.ts 98.53% <0.00%> (+0.32%) ⬆️
dev/src/document.ts 98.68% <0.00%> (+0.37%) ⬆️
dev/src/pool.ts 98.40% <0.00%> (+0.40%) ⬆️
... and 6 more

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 eb1b4dc...8744b9c. Read the comment docs.

Copy link
Contributor

@dconeybe dconeybe left a comment

Choose a reason for hiding this comment

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

Just one drive-by comment.

dev/src/collection-group.ts Show resolved Hide resolved
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

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

Thanks. Some nits, some optional nits :)

We also need to update the types file.

* Firestore.
* @param {FirestoreDataConverter | null} converter Converts objects to and
* from Firestore. Passing in `null` applies the default `DocumentData` typed
* converter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe: Passing in null removes the current converter.

Up to you.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, this is clearer since users might not have the concept of a default converter.

): CollectionGroup<U> {
return new CollectionGroup<U>(
this.firestore,
this._queryOptions.collectionId,
converter
converter !== null ? converter : defaultConverter()
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is NodeJS and we don't care as much about code size, you could also use converter ?? defaultConverter.

Copy link
Author

Choose a reason for hiding this comment

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

done.

@@ -148,6 +148,7 @@ describe('Firestore class', () => {
});

it('getAll() supports generics', async () => {
randomCol.doc('lo')._converter;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm.

Copy link
Author

Choose a reason for hiding this comment

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

oops.

Comment on lines 744 to 745
// Check that the Post class's toString() override does not apply.
expect(posts.docs[0].data().toString()).to.equal('[object Object]');
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not do an instanceof check here?

Copy link
Author

Choose a reason for hiding this comment

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

good point.

@@ -741,8 +742,7 @@ describe('query interface', () => {

const posts = await coll.where('title', '==', 'post').get();
expect(posts.size).to.equal(1);
// Check that the Post class's toString() override does not apply.
expect(posts.docs[0].data().toString()).to.equal('[object Object]');
expect(posts.docs[0].data() instanceof Post).to.be.false;
Copy link
Contributor

Choose a reason for hiding this comment

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

to.not.be.an.instanceof

Copy link
Author

Choose a reason for hiding this comment

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

learn2chai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants