【发布时间】:2018-05-13 16:07:55
【问题描述】:
我不得不重新表述这个问题,因为它有点误导(我的错)。
这是我的困境,假设我有一个聚会收藏:
parties {
status: "open",
invitees: [56486,68978,897650], # user ids of invited users
scheduled_at: 1948089050 # timestamp
}
我只想查询受邀参加的“公开”派对(我在受邀者数组中的用户 ID),并按 scheduled_at 排序
我可以通过将数组转换为哈希来解决查询数组的第一部分(感谢@renaud 和@james poag):
parties {
status: "open",
invitees: {
56486: true,
68978: true,
897650: true
}
scheduled_at: 1948089050
}
现在执行这个:
db.collection('parties').where('status', '==', 'open').where('invitees.56486', '==', true').orderBy('scheduled_at')
导致 Firebase 错误,要求我为 status + invitees.56486 + scheduled_at 创建复合索引。如您所见,为每个用户 ID 添加索引对我来说是不切实际的。
有什么想法吗?
【问题讨论】:
标签: firebase google-cloud-firestore