Add getDocuments and getDocumentsData functions - #11
Conversation
|
@cursor review |
There was a problem hiding this comment.
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
getDocumentsfunction that returnsFsMutableDocument<T>[] - Added
getDocumentsDatafunction that returnsT[] - Both functions accept a typed
CollectionReferenceand 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.
There was a problem hiding this comment.
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.
| const _query = | ||
| queryConstraints.length === 0 | ||
| ? query(collectionRef, limit(500)) | ||
| : query(collectionRef, ...queryConstraints); |
There was a problem hiding this comment.
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.


Non-hook equivalents of
useCollectionfor fetching collection documents once usinggetDocs(). Both functions accept a typedCollectionReferenceand optional query constraints.getDocumentsreturnsFsMutableDocument<T>[]getDocumentsDatareturnsT[]Closes #1