Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

explanation of firebase docs about query(query, queryConstraints)?

I was looking about more details about the query function in firestore in docs reference of firestore and I found this pseudo syntax :

query(query, queryConstraints)

but in all firestore examples about this function they used in the first parameter a collection reference not query

form firestore examples :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

// Create a reference to the cities collection
import { collection, query, where } from "firebase/firestore";
const citiesRef = collection(db, "cities");

// Create a query against the collection.
const q = query(citiesRef, where("state", "==", "CA"));

Is it the same function or this this another Signature for it ?

>Solution :

A collection reference is a subclass of a query, so wherever the API expects a Query you can also pass a CollectionReference. So you can build a new query by passing a CollectionReference to the query function, or add conditions to an existing query by passing a Query to it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading