Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Firestore手动输入索引?_Javascript_Firebase_Google Cloud Firestore - Fatal编程技术网

Javascript Firestore手动输入索引?

Javascript Firestore手动输入索引?,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,我有以下疑问: get invitations() { return this.firestore.colWithIds$(`users/${this.authProvider.currentUserId}/meetings`, (ref) => { return ref .where(`participants.${this.authProvider.currentUserId}.invitation`, '==', 'pending') .o

我有以下疑问:

get invitations() {
    return this.firestore.colWithIds$(`users/${this.authProvider.currentUserId}/meetings`, (ref) => {
      return ref
      .where(`participants.${this.authProvider.currentUserId}.invitation`, '==', 'pending')
      .orderBy('createdAt', 'desc')
    });
  }
每次Firebase都会生成一个错误,说明:此查询需要一个索引,并生成一个包含
currentUserId
的链接。我将其添加到控制台,一切都按预期进行


然而,在用户注册时,这似乎有点过于手动,无法维护。我如何生成一个动态索引,而不需要每次新用户下载我的应用程序时手动输入

在一般情况下,您想要执行的查询在具有您的数据结构的Cloud Firestore中是不可能的

您很快就会遇到每个数据库200个复合索引的限制,可能是您的第200个用户:

您好,谢谢您的回复。我每次会议最多有20名与会者。所以我永远无法达到这个极限。有没有办法解决这个问题。。。没有创建索引,因为我不相信它在我当前的场景中有用。(也许我可以删除orderBy并在客户端上进行.sort,这是否理想?考虑到我有20个参与者的限制?)整个数据库上有200个自定义索引,因此我认为您仍然会满足此限制。删除orderBy并在客户端上进行排序肯定是一个不错的选择,因为您没有使用
limit()
因此您不需要服务器排序。