相关疑难解决方法(0)

如何在使用实时更新时检查是否存在云防火墙文档

这有效:

db.collection('users').doc('id').get()
  .then((docSnapshot) => {
    if (docSnapshot.exists) {
      db.collection('users').doc('id')
        .onSnapshot((doc) => {
          // do stuff with the data
        });
    }
  });
Run Code Online (Sandbox Code Playgroud)

......但似乎很冗长.我试过doc.exists,但那没用.我只想在订阅文档上的实时更新之前检查文档是否存在.那个初始的get似乎是对db的一个腰部调用.

有没有更好的办法?

javascript google-cloud-firestore

26
推荐指数
2
解决办法
3万
查看次数

在Cloud Firestore中检查文档字段以查找特定值

我想用自定义用户名创建用户注册.我将用户的用户名存储在Firestore中的用户文档中.如何验证用户集中已存在的用户名?

也许有人已经有反应表格验证的片段?

firebase google-cloud-datastore angularfire2 angular google-cloud-firestore

1
推荐指数
1
解决办法
2738
查看次数