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

fix(firestore): handle parent correctly in doc and collection #7922

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/firestore/lib/modular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
if (pathSegments && pathSegments.length) {
path = path + '/' + pathSegments.map(e => e.replace(/^\/|\/$/g, '')).join('/');
}

Check failure on line 47 in packages/firestore/lib/modular/index.js

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`

Check failure on line 47 in packages/firestore/lib/modular/index.js

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`

Check failure on line 47 in packages/firestore/lib/modular/index.js

View workflow job for this annotation

GitHub Actions / Lint

Delete `··`
if ('collection' in parent) {
const [firstSegment, ...restSegments] = path.split('/');
return parent.collection(firstSegment).doc(restSegments.join('/'));

Check warning on line 50 in packages/firestore/lib/modular/index.js

View check run for this annotation

Codecov / codecov/patch

packages/firestore/lib/modular/index.js#L49-L50

Added lines #L49 - L50 were not covered by tests
}

return parent.doc(path);
}
Expand All @@ -59,6 +64,11 @@
path = path + '/' + pathSegments.map(e => e.replace(/^\/|\/$/g, '')).join('/');
}

if ('doc' in parent) {
const [firstSegment, ...restSegments] = path.split('/');
return parent.doc(firstSegment).collection(restSegments.join('/'));

Check warning on line 69 in packages/firestore/lib/modular/index.js

View check run for this annotation

Codecov / codecov/patch

packages/firestore/lib/modular/index.js#L68-L69

Added lines #L68 - L69 were not covered by tests
}

return parent.collection(path);
}

Expand Down
Loading