首页 > 解决方案 > 无法执行多个查询索引的 Firestore 集合

问题描述

所以我尝试使用这个函数从firebase获取数据

getData(){
        const startDate = this.$store.state.inputFilter.rangeDate.start
        const endDate = this.$store.state.inputFilter.rangeDate.end
        db.collection(this.inputType)
        .where('idAlat', '==',this.equipment)
        .where('tanggal', '>=', startDate).where('tanggal', '<=', endDate)
        .where('project', '==', this.project)
        .get().then(docs => {
            docs.forEach(doc => {
                console.log(doc.data().tanggal.toDate(), doc.data().idAlat)
            })
        })
    }

但是每次我尝试运行该功能时,它都会在控制台中显示如下错误: 控制台中的错误

但是然后我按照链接并按照说明在firebase中创建复合索引,如下所示: Firestore 索引设置

我做错了什么吗?谢谢!

PS:“tanggal”一词在英语中的意思是“日期”

标签: javascriptfirebasegoogle-cloud-firestore

解决方案


推荐阅读