【发布时间】: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