Skip to content

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

Merged
merged 2 commits into from
Jul 16, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

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 support collection(coll, 'a/b'). This matches the behavior of this method when call with db (Firestore) already.

The same change is made for doc.

@changeset-bot
Copy link

changeset-bot bot commented Jul 14, 2020

💥 No Changeset

Latest 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 changesets

When 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

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Jul 14, 2020

Binary Size Report

Affected SDKs

  • @firebase/analytics

    Type Base (b07f822) Head (fddbbd2) Diff
    esm2017 8.68 kB 9.66 kB +975 B (+11.2%)
    main 9.69 kB 10.9 kB +1.20 kB (+12.3%)
    module 9.37 kB 10.6 kB +1.22 kB (+13.0%)
  • @firebase/auth

    Type Base (b07f822) Head (fddbbd2) Diff
    browser ? 177 kB ? (?)
  • @firebase/database

    Type Base (b07f822) Head (fddbbd2) Diff
    browser 268 kB 269 kB +848 B (+0.3%)
    esm2017 235 kB 236 kB +523 B (+0.2%)
    main 269 kB 270 kB +848 B (+0.3%)
    module 267 kB 268 kB +843 B (+0.3%)
  • @firebase/firestore/exp

    Type Base (b07f822) Head (fddbbd2) Diff
    main 400 kB 400 kB +638 B (+0.2%)
  • @firebase/firestore/lite

    Type Base (b07f822) Head (fddbbd2) Diff
    main 124 kB 125 kB +638 B (+0.5%)
  • @firebase/util

    Type Base (b07f822) Head (fddbbd2) Diff
    browser 19.6 kB 20.5 kB +921 B (+4.7%)
    esm2017 17.5 kB 18.3 kB +786 B (+4.5%)
    main 19.6 kB 20.5 kB +921 B (+4.7%)
    module 18.7 kB 19.5 kB +832 B (+4.5%)
  • firebase

    Type Base (b07f822) Head (fddbbd2) Diff
    firebase-analytics.js 26.6 kB 28.0 kB +1.37 kB (+5.1%)
    firebase-database.js 187 kB 187 kB +18 B (+0.0%)
    firebase.js 819 kB 820 kB +1.39 kB (+0.2%)

Test Logs

Copy link

@thebrianchen thebrianchen left a 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 (

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?

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@schmidt-sebastian schmidt-sebastian merged commit 5b7d812 into master Jul 16, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/accesshelpers branch July 17, 2020 01:40
@firebase firebase locked and limited conversation to collaborators Aug 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants