Complete the code to access a Firestore collection using the GCP client.
gcp_client = firestore.Client() db = gcp_client.[1]('users')
The collection() method is used to access a NoSQL collection in Firestore.
Complete the code to add a document to a Firestore collection.
doc_ref = db.[1]('users').document('user1') doc_ref.set({'name': 'Alice', 'age': 30})
get or delete which do not create collections.The collection() method accesses the 'users' collection to add a document.
Fix the error in the Firestore query to retrieve documents where age is greater than 25.
query = db.collection('users').where('age', '[1]', 25)
The operator '>' is used to filter documents where age is greater than 25.
Fill both blanks to create a Firestore document update that changes the user's age and adds a new field.
doc_ref.update({'[1]': 31, '[2]': 'active'})The fields age and status are updated in the document.
Fill all three blanks to create a Firestore query that orders users by age descending and limits results to 5.
query = db.collection('[1]').order_by('[2]', direction='[3]').limit(5)
The query accesses the 'users' collection, orders by 'age' descending, and limits to 5 results.