我正在使用 reactjs,我的数据库是 firebase。
我正在尝试发送一个群组的邀请。传递给函数的变量是组的 id (groupID)、组的名称 (groupName)(不用于检查但传递给邀请函数)以及被邀请者的电子邮件地址 (invite)。它检查邀请是否已经存在,如果不存在,它会调用邀请代码,如果不存在,它只会发送一个警报,说明用户已经有一个邀请。这是我的检查代码:
await props.firestore
.collection("invites")
.where("groupID", "==", groupID)
.where("invitee", "==", invite)
.get()
.then(async (invitation) => {
if (invitation.exists) {
alert("User already has invite");
} else {
// Send Invite!
await props.firestore
.collection("invites")
.add({})
.then(async (ref) => {
SendInvite(invite,groupID,groupName);
alert("INVITE SENT");
});
}
});