I have a React project and in it I have the following code: (using this react hook for firebase)
const messagesRef = firestore.collection('messages');
const query = messagesRef.orederBy('createdAt').limit(25);
const [messages] = useCollectionData(query, {idField: 'id'});
Instead of this, I don't want the query to be ordered or have a limit, is there a way to make an "empty" query to get all the data from a certain collection?
If you pass messagesRef
instead of a query with orderBy()
and limit()
then the query should fetch all documents in the collection since a CollectionReference is a subclass of a Query:
const messagesRef = firestore.collection('messages');
const [messages] = useCollectionData(messagesRef, {idField: 'id'});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.