api/src/main/java/com/google/sps/ValidateUsername.java
// Takes a username and checks for its existence in the database
Takes a username and checks for its existence in the database
Takes a username and checks for its existence in the database
private static Boolean isUniqueUsername(String username) throws Exception {
    Firestore db = FirestoreClient.getFirestore();
    CollectionReference users = db.collection("users");
    Query query = users.whereEqualTo("username", username);
    ApiFuture<QuerySnapshot> querySnapshot = query.get();
    List<QueryDocumentSnapshot> queryDocuments = querySnapshot.get().getDocuments();
    if (queryDocuments.isEmpty()) {
      return true;
    }
    return false;
  }
private static Boolean isUniqueUsername ( String username ) throws Exception { Firestore db = FirestoreClient . getFirestore ( ) ; CollectionReference users = db . collection ( "users" ) ; Query query = users . whereEqualTo ( "username" , username ) ; ApiFuture < QuerySnapshot > querySnapshot = query . get ( ) ; List < QueryDocumentSnapshot > queryDocuments = querySnapshot . get ( ) . getDocuments ( ) ; if ( queryDocuments . isEmpty ( ) ) { return true ; } return false ; }
Takes a username and checks for its existence in the database
Takes a username and checks for its existence in the database