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 :
// 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 ?
CodePudding user response:
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.