Skip to content

Add getDocuments and getDocumentsData functions - #11

Merged
0x80 merged 3 commits into
mainfrom
thijs/0220-add-get-documents
Feb 20, 2026
Merged

Add getDocuments and getDocumentsData functions#11
0x80 merged 3 commits into
mainfrom
thijs/0220-add-get-documents

Conversation

@0x80

@0x80 0x80 commented Feb 20, 2026

Copy link
Copy Markdown
Owner

Non-hook equivalents of useCollection for fetching collection documents once using getDocs(). Both functions accept a typed CollectionReference and optional query constraints.

  • getDocuments returns FsMutableDocument<T>[]
  • getDocumentsData returns T[]

Closes #1

Copilot AI review requested due to automatic review settings February 20, 2026 16:44
@0x80

0x80 commented Feb 20, 2026

Copy link
Copy Markdown
Owner Author

@cursor review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds non-hook equivalents of useCollection for one-time document fetching, addressing issue #1 where getDocuments was referenced in documentation but not exported. The functions provide a way to fetch collection documents using getDocs() outside of React components, useful for integration with libraries like ReactQuery.

Changes:

  • Added getDocuments function that returns FsMutableDocument<T>[]
  • Added getDocumentsData function that returns T[]
  • Both functions accept a typed CollectionReference and optional query constraints

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/index.ts Added export for new get-documents module in alphabetical order
src/get-documents.ts Implemented getDocuments and getDocumentsData functions following established patterns from get-document.ts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/get-documents.ts Outdated
@0x80
0x80 merged commit ec5c643 into main Feb 20, 2026
3 checks passed

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment thread src/get-documents.ts
const _query =
queryConstraints.length === 0
? query(collectionRef, limit(500))
: query(collectionRef, ...queryConstraints);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated query-building logic in same file

Low Severity

The query-building block (checking queryConstraints.length, applying limit(500) default, or spreading user constraints) is duplicated verbatim between getDocuments and getDocumentsData in the same file. If the default behavior ever changes (e.g., adjusting the default limit), both copies need to be updated in sync, risking divergence. A small shared helper within this file would eliminate that risk.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No getDocuments function

2 participants