How can I check if a value e.g. name exists in a collection within any of documents in Cloud Firestore?
问题 I want to check if a value e.g. (name: ‘John’) exists in the collection of any document in my Cloud Firestore, because if it does I do not want to create a new document with that name (in this case ‘John’). How can I check if the name exists? 回答1: Assuming you have in Firestore a collection called "users", to check if a user with the name of "John" already exists, please use the following lines of code: FirebaseFirestore rootRef = FirebaseFirestore.getInstance(); CollectionReference usersRef