未捕获(承诺)错误:查询需要索引 [英] Uncaught (in promise) Error: The query requires an index

查看:40
本文介绍了未捕获(承诺)错误:查询需要索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我添加了 Where 方法,我就会收到此错误,但它可以在没有 Where 子句的情况下工作.在集合中,每个文档都有称为状态"的布尔值.

I get this error once I added the Where method, but it works without the Where clause. In collection every document has Boolean called "status".

db.firestore().collection('jobs').where("status","==",true).orderBy("createDate").limit(10).get().then(querySnapshot =>{

        })
      })

感谢所有帮助.谢谢!

推荐答案

由于您要查询两个字段(statuscreateDate),因此需要有一个这两个字段的复合索引.单个字段的索引是自动创建的,但复合索引仅在您要求时创建.

Since you're querying on two fields (status and createDate), there needs to be a composite index on those two fields. Indices on individual fields are automatically created, but composite indexes are only created when you ask for them.

错误消息应包含直接指向控制台的链接以完成该任务.如果不是这种情况,您可以在此处创建一>.

The error message should contain a link directly to the console to complete that task. If that's not the case, you can create it here.

这篇关于未捕获(承诺)错误:查询需要索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆