Complete the code to get an instance of Firestore.
val db = FirebaseFirestore.[1]()The correct method to get a Firestore instance is getInstance().
Complete the code to add a new document to the 'users' collection.
db.collection("users").[1](userData)
Use add() to add a new document with generated ID to a collection.
Fix the error in the code to listen for realtime updates on 'messages' collection.
db.collection("messages").addSnapshotListener { snapshots, [1] -> if (error != null) { return@addSnapshotListener } // process snapshots }
The listener callback uses throwable to check for problems.
Fill both blanks to update the 'age' field of a document with ID 'userId' in 'users' collection.
db.collection("users").document(userId).[1](mapOf("age" to [2]))
Use update() to change specific fields. The age value here is 25.
Fill all three blanks to query 'products' collection for items with price greater than 100 and order by price ascending.
db.collection("products").whereGreaterThan("[1]", [2]).orderBy("[3]")
We filter by 'price' greater than 100 and order by 'price'.
