我想在 Where Query 中使用可验证来访问用户集合中的用户数据。我使用此代码,但数据未检索:
export const userAddToOrganization = (email) => {
return (dispatch) => {
if (email !== '') {
console.log('email' , email); //'e@e.com √'
firebase.firestore().collection('users').where("email", '==', `${email}`)
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.id, "=>", doc.data());
});
});
}
};
};
当我用作"e@e.com">时,数据检索成功。但我想使用可验证的(电子邮件(
export const userAddToOrganization = (email) => {
return (dispatch) => {
if (email !== '') {
console.log('email' , email);
firebase.firestore().collection('users').where("email", '==', 'e@e.com')
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.id, "=>", doc.data());
});
});
}
};
};
如何在 WHERE 查询中使用可验证来获取数据。谢谢。
export const userAddToOrganization = (email) => {
return (dispatch) => {
if (email !== '') {
console.log('email' , email); //'e@e.com √'
const ref = firebase.firestore().collection('users')
ref.where("email", '==', email)
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.id, "=>", doc.data());
});
});
}
};
};
我还没有测试过它,但我认为没有理由它不应该工作。删除字符串文字并直接传递电子邮件。如果这不起作用,那么我想会修剪字符串,这会删除所有多余的空间。
export const userAddToOrganization = (email) => {
return (dispatch) => {
if (email !== '') {
console.log('email' , email); //'e@e.com √'
const ref = firebase.firestore().collection('users')
ref.where("email", '==', email.trim())
.get()
.then((querySnapshot) => {
querySnapshot.forEach((doc) => {
console.log(doc.id, "=>", doc.data());
});
});
}
};
};