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

Use limitToLast instead of limit in the query #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

orhalimi
Copy link

Prevent awkwardness when the db will have more than 25 documents. Getting the last N documents while maintaining ASC order.

Prevent awkwardness when the db will have more than 25 documents. Getting the last N documents while maintaining ASC order.
@ralfs66
Copy link

ralfs66 commented Apr 30, 2023

ERROR in src/App.tsx:92:65
TS2339: Property 'limitToLast' does not exist on type 'QueryOrderByConstraint'.
90 | const dummy = useRef() as React.MutableRefObject
91 | const messagesRef = collection(db, 'messages')

92 | const messagesQuery = query(messagesRef, orderBy('createdAt').limitToLast(25) )
| ^^^^^^^^^^^
93 |
94 | const [messages, loading, error] = useCollection(messagesQuery, {
95 | snapshotListenOptions: { includeMetadataChanges: true },

@ralfs66
Copy link

ralfs66 commented Apr 30, 2023

import {
addDoc,
collection,
getFirestore,
orderBy,
query,
limitToLast,
Timestamp,
} from 'firebase/firestore'

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.

2 participants