Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.

feat: add support for recursive queries#407

Merged
craiglabenz merged 15 commits into
masterfrom
recursive-query
Aug 11, 2021
Merged

feat: add support for recursive queries#407
craiglabenz merged 15 commits into
masterfrom
recursive-query

Conversation

@craiglabenz

Copy link
Copy Markdown
Contributor

Adds the ability for queries to begin fetching all nested documents regardless of their collection name. Previously, the only similar mechanic available was the all_descendants parameter (available via the collection_group class), which is imperfectly named and in fact only fetches all descendants with the same parent name. So, for example:

/users/alfred
/users/alfred/pets/scruffy
/users/alfred/users/alfreds-butler

In this case, running db.collection_group('users').get() would fetch /users/alfred and /users/alfred/users/alfreds-butler, but NOT /users/alfred/pets/scruffy.

Not that this is decidedly not all of Alfred's descendants.


And thus: Recursive Queries ™️. Starting now, to fetch all three documents from the above hypothetical, a developer would run one of these two options:

db.collection_group('users').recursive().get()
# or this similar statement with an identical outcome:
db.collections('users').recursive().get()
@craiglabenz craiglabenz requested review from a team July 29, 2021 21:17
@product-auto-label product-auto-label Bot added the api: firestore Issues related to the googleapis/python-firestore API. label Jul 29, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 29, 2021
@craiglabenz craiglabenz requested a review from crwilcox July 29, 2021 22:27
@dandhlee dandhlee added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 30, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 30, 2021
@tseaver tseaver changed the title feat: added recursive query Aug 9, 2021
Comment thread google/cloud/firestore_v1/_helpers.py Outdated
Comment thread google/cloud/firestore_v1/base_collection.py Outdated
@craiglabenz craiglabenz added the automerge Merge the pull request once unit tests and other checks pass. label Aug 10, 2021
@craiglabenz craiglabenz merged commit eb45a36 into master Aug 11, 2021
@craiglabenz craiglabenz deleted the recursive-query branch August 11, 2021 13:02
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Aug 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: firestore Issues related to the googleapis/python-firestore API. cla: yes This human has signed the Contributor License Agreement.

5 participants