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 set() with SetOptions when using FirestoreDataConverter #1087

Merged
merged 15 commits into from
May 21, 2020

Conversation

thebrianchen
Copy link

@thebrianchen thebrianchen commented May 21, 2020

Fixes #1000.

@thebrianchen thebrianchen self-assigned this May 21, 2020
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 21, 2020
@codecov
Copy link

codecov bot commented May 21, 2020

Codecov Report

Merging #1087 into node10 will increase coverage by 0.00%.
The diff coverage is 96.25%.

Impacted file tree graph

@@           Coverage Diff           @@
##           node10    #1087   +/-   ##
=======================================
  Coverage   98.62%   98.63%           
=======================================
  Files          28       28           
  Lines       17944    18005   +61     
  Branches     1394     1399    +5     
=======================================
+ Hits        17698    17759   +61     
  Misses        243      243           
  Partials        3        3           
Impacted Files Coverage Δ
dev/src/index.ts 98.18% <93.75%> (ø)
dev/src/bundle.ts 93.80% <93.80%> (ø)
dev/src/reference.ts 99.88% <98.73%> (+<0.01%) ⬆️
dev/src/bulk-writer.ts 98.82% <100.00%> (+0.03%) ⬆️
dev/src/document.ts 98.76% <100.00%> (ø)
dev/src/transaction.ts 97.02% <100.00%> (+0.02%) ⬆️
dev/src/types.ts 99.72% <100.00%> (+0.01%) ⬆️
dev/src/watch.ts 99.14% <100.00%> (ø)
dev/src/write-batch.ts 100.00% <100.00%> (ø)
... and 2 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 19b8922...47cd5ee. Read the comment docs.

let firestoreData: DocumentData;
if (mergeLeaves || mergePaths) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
firestoreData = (documentRef._converter as any).toFirestore(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a short comment on why we need this cast to any.

Copy link
Author

Choose a reason for hiding this comment

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

done.

@@ -342,6 +342,19 @@ export const postConverter = {
},
};

export const postConverterMerge = {
toFirestore(post: Partial<Post>): DocumentData {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add SetOptions here and additional asserts? Something like that:

if (merge) {
expect(post).to.be.an.instanceOf(Post);
} else {
expect(post).to.not.be.an.instanceOf(Post);
}

Copy link
Author

Choose a reason for hiding this comment

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

Done, but flipped the expect statements.

const untypedReference = new DocumentReference(
this.ref.firestore,
this.ref._path
);
return this.ref._converter.fromFirestore(
return ((this.ref._converter as unknown) as FirestoreDataConverter<
Copy link
Contributor

Choose a reason for hiding this comment

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

This compiles for me as just "this.ref._converter.fromFirestore".

Copy link
Author

Choose a reason for hiding this comment

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

done.

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.

LGTM, minus lint fixes

@schmidt-sebastian
Copy link
Contributor

Do you want to make this a "feat" before merging? This deserves more recognition :)

@thebrianchen thebrianchen changed the title fix: Add support for set() with converters feat: Add support for set() with converters May 21, 2020
@thebrianchen thebrianchen changed the title feat: Add support for set() with converters feat: add support for set() with SetOptions when using FirestoreDataConverter May 21, 2020
@thebrianchen thebrianchen merged commit 2254650 into node10 May 21, 2020
@thebrianchen thebrianchen deleted the bc/merge-override branch May 24, 2020 16:17
schmidt-sebastian added a commit that referenced this pull request Jun 24, 2020
* fix!: mark v1beta1 client as deprecated (#937)

* feat!: use QueryDocumentSnapshot in FirestoreDataConverter (#965)

* deps: update to gts 2.x (#1013)

* chore!: update settings for Node 10 (#1019)

* deps: drop through2 (#1014)

* feat: support BigInt (#1016)

* fix: make update.sh work on Linux (#1043)

* fix: only use BigInt in BigInt system test (#1044)

* fix: make pbjs compile admin proto again (#1045)

* Add BulkWriter (#1055)

* docs: Add documentation for FirestoreDataConverter (#1059)

* chore: enforce return types (#1065)

* fix: add generic to Firestore.getAll() (#1066)

* chore: remove internal WriteOp (#1067)

* chore: add linter checks for it|describe.only (#1068)

* fix: handle terminate in BulkWriter (#1070)

* chore: run template copying last in synthtool (#1071)

* feat: Firestore Bundles implementation (#1078)

* feat: add support for set() with SetOptions when using FirestoreDataConverter (#1087)

* feat: Add totalDocuments and totalBytes to bundle metadata. (#1085)

* feat: Add totalDocuments and totalBytes to bundle metadata.

* fix: Better comment

* fix: Better testing.

* fix: Improve metadata testing.

* fix: incomplete expect in rate-limiter test (#1092)

* Remove BatchWrite proto, fix conformance tests

* chore: use public API types internally (#1100)

* feat: add Partition and BatchWrite protos (#1110)

* fix: remove GCF transaction fallback (#1112)

* fix: add BulkWriter integration tests, java backport changes, delete fix (#1117)

* chore: merge master (#1218)

* chore: add eslint check for console.log statements (#1229)

* fix: another attempt at fixing the flaky BulkWriter test (#1228)

* Fix comment

* Renames

* Test fix

* Fix unit tests

Co-authored-by: Brian Chen <chenbrian@google.com>
Co-authored-by: wu-hui <53845758+wu-hui@users.noreply.github.com>
@release-please release-please bot mentioned this pull request Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants