async function checkUserExistsParallel(email, phone) {
try {
const checks = [];
if (email) {
checks.push(
getDocs(query(
collection(db, 'users'),
where('email', '==', email),
limit(1)
))
);
}
if (phone) {
checks.push(
getDocs(query(
collection(db, 'users'),
where('phone', '==', phone),
limit(1)
))
);
}
const snapshots = await Promise.all(checks);
const results = {
exists: snapshots.some(snap => !snap.empty),
byEmail: email ? !snapshots[0].empty : false,
byPhone: phone ? !snapshots[email ? 1 : 0].empty : false
};
return results;
} catch (error) {
console.error("Error checking user existence:", error);
return { exists: false, byEmail: false, byPhone: false, error: error.message };
}
}