我正在使用firestore来查询带有复合查询的文档,我的代码是:
let query = firestore.collection( 'market' )
let res = []
let newChkPt = false
// states
query = query.where('deListTime', '==', false)
query = query.where('tradeTime' , '==', false)
query = query.where('expirationTime', '>', Date.now())
// FIFO ordering
query = query.orderBy('originationTime', 'desc')
query = query.limit(3)
if (chkPt) {
await query
.startAfter(chkPt)
.get()
.then(snap => {
snap.forEach(doc => {
res.push(doc.data());
newChkPt = doc.data()['originationTime']
})
})
.catch(e => { console.log(e); return false})
} else {
await query
.get()
.then(snap => {
snap.forEach(doc => {
res.push(doc.data());
newChkPt = doc.data()['originationTime']
})
})
.catch(e => { console.log(e); return false})
}在控制台中,我在字段deListTime、tradeTime、expirationTime和originationTime之间指定了可能的每种组合复合查询索引。然而,我指定的这个复合查询拒绝按预期获取数据。如果我注释掉
query = query.orderBy('originationTime', 'desc') 我得到了数据,如果我注释掉了'>‘,而其他所有内容都没有注释:
query = query.where('expirationTime', '>', now)我还可以获得所需的数据。是>把事情搞砸了吗?
索引:



发布于 2019-04-11 01:29:54
你在什么地方初始化'now‘吗?你是说Date.now()吗?
https://stackoverflow.com/questions/55618189
复制相似问题