node.js - 使用组合查询时 Firebase Firestore 返回空数组
问题描述
我正在尝试在同一个 firebase 查询中组合两个过滤器。当我尝试仅使用搜索查询时,它完美地工作并且与日期范围查询相同。但是当我结合这两个查询时,它返回一个空数组。我不明白为什么会这样。这是我的组合查询。它有什么问题。
export const getUsers = async (minDate:Date, maxDate:Date) => {
admin
.firestore()
.collection("users")
.where("name", ">=", "abc")
.where('name', "<=", "abc"+"~")
.orderBy('name', "asc")
.orderBy('createdAt')
.startAt(admin.firestore.Timestamp.fromDate(new Date(minDate)))
.endAt(admin.firestore.Timestamp.fromDate(new Date(maxDate)))
.get()
.then(async (DS) => {
if ( DS ) {
const arr: any[] = [];
await DS.docs.forEach(doc=>{
arr.push(doc.data())
})
functions.logger.info(
"get successfully - ",
await DS.docs
);
return arr;
} else {
throw new functions.https.HttpsError(
"invalid-argument",
""
);
}
})
.catch((error) => {
throw new functions.https.HttpsError(
"invalid-argument",
error.message
);
});
}
我在云功能中使用firebase admin,并且所有索引都是由firebase建议的。
解决方案
推荐阅读
- python - 如果在 cmd 中运行,这可能在 python 中吗?
- javascript - 不能使用 React 上下文?
- junit - 使用 Mockito/powermock 模拟静态方法对象
- sql - 在 SQLite 中仅使用 SQL 更新和记录更改的行
- c# - TransactionScope 超出范围有效值translationIsolation错误
- python - 使用图表分析目录内容质量随时间的演变
- android-gradle-plugin - gradle 问题描述中的详细信息
- javascript - 如果状态为空,如何清除 React Material AutoComplete 选定的标签?
- flutter - Flutter 用户数据占用大量空间
- windows - 教程:如何使用 WinDbg / KD 启动调试 VirtualBox Windows 虚拟机?