[firestore docs] Question about query name in firestore snippets
Opened this issue · 1 comments
binarygondola commented
snippets-node/firestore/main/index.js
Line 590 in cccc005
in simpleQuery function, reference to a collection is named citiesRef (1) and query on this ref is named queryRef (2) - both with ref at the end. Only the result of the query is named res (3)
async function simpleQuery(db) {
// Create a reference to the cities collection
const citiesRef = db.collection('cities'); // (1)
// Create a query against the collection
const queryRef = citiesRef.where('state', '==', 'CA'); // (2)
// [END firestore_query_filter_eq_string]
const res = await queryRef.get(); // (3)
res.forEach(doc => {
console.log(doc.id, ' => ', doc.data());
});
}however in queryAndFilter function we have a query on a ref that ends with a res in the variable name (1). Shouldn't it be called allCapitalsRef? What is the proper naming convention?
async function queryAndFilter(db) {
// Create a reference to the cities collection
const citiesRef = db.collection('cities');
// Create a query against the collection
const allCapitalsRes = citiesRef.where('capital', '==', true); // (1)
// ...rest of the function
}The code is provided at https://firebase.google.com/docs/firestore/query-data/queries#simple_queries
davidjacobs153-design commented
- [`