-
Notifications
You must be signed in to change notification settings - Fork 939
Add support for collection(coll) and doc(doc) #3403
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
Conversation
💥 No ChangesetLatest commit: 10f89b2 Merging this PR will not cause any packages to be released. If these changes should not cause updates to packages in this repo, this is fine 🙂 If these changes should be published to npm, you need to add a changeset. This PR includes no changesetsWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Click here to learn what changesets are, and how to add one. Click here if you're a maintainer who wants to add a changeset to this PR |
Binary Size ReportAffected SDKs
Test Logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
} else { | ||
const doc = cast(parent, DocumentReference); | ||
const absolutePath = doc._key.path.child(path); | ||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would we hit this error block in TS since the arguments are typed? Or is this for JS users? How could you test that this works properly in TS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be hit if someone passes a DocumentReference-looking type into our SDK. Our external types only validate that type passed in looks like a DocumentReference (has all the same properties) but they cannot enforce that the provided type is an actual instance of DocumentReference.
new DocumentKey(absolutePath), | ||
coll._converter | ||
parent instanceof CollectionReference ? parent._converter : null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test to make sure the converter is properly passed/omitted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
This adds new methods, which are pending review in go/firestore-next-amendment.
The new collection methods allows direct access to subcollections. Instead of
collection(doc(coll, 'a'), 'b')
we now supportcollection(coll, 'a/b')
. This matches the behavior of this method when call withdb
(Firestore) already.The same change is made for
doc
.