【发布时间】:2020-06-06 01:17:42
【问题描述】:
我是 firestore 新手,我正在使用 vue 创建一个注册页面。 在创建新用户之前,它必须检查给定的用户名是否已经存在,如果不存在,则创建一个新用户。
我可以在数据库中添加一个新用户,但我不知道如何检查用户名是否已经存在。我尝试了很多东西,这是我得到的最接近的:
db.collection("Users")
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
if (this.username === doc.data().username) {
usernameExist = true;
}
});
});
有人有什么想法吗?
【问题讨论】:
标签: javascript firebase vue.js google-cloud-firestore