Search Query With Firestore

  const getUSerDataByEmail = async (email) => {
    try {
      let arr = [];
      const q = query(
        collection(db, "users"),
        where("email_user", ">=", email),  //
        where("email_user", "<=", email + "\uf8ff")
      );
      const querySnapshot = await getDocs(q);
      querySnapshot.forEach((doc) => {
        arr.push(doc.data());
      });
      setUserData(arr);
      return arr;
    } catch (error) {
      console.log(error);
    }
  };

Last updated

Was this helpful?