【问题标题】:Listen for Query FAILED_PRECONDITION The query requires an index侦听查询 FAILED_PRECONDITION 查询需要索引
【发布时间】:2020-06-26 16:19:21
【问题描述】:

我正在尝试使用多个索引执行复合查询。但我收到以下错误

侦听查询(collectionGroup=groupNotifications where receivers array_contains jPvdUmIb05aeZeRPtFTwX3idKPm1 order by -createdAt)失败:状态{code=FAILED_PRECONDITION, description=查询需要索引。

这是我的查询

  Future<GroupNotificationModel> latestGroupNotification() async => _firestore
      .collectionGroup('groupNotifications')
      .where('receivers', arrayContains: user.id)
      .orderBy('createdAt', descending: true)
      .limit(1)
      .getDocuments()
      .then((value) => GroupNotificationModel.fromMap(value.documents.first.data));

我按以下方式设置索引

那么为什么我会收到错误消息?我添加了索引。

【问题讨论】:

    标签: firebase dart google-cloud-firestore


    【解决方案1】:

    答案是按正确的顺序排列索引

    【讨论】:

      猜你喜欢
      • 2020-02-02
      • 1970-01-01
      • 2018-12-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-19
      • 2020-06-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多