如果它是文本字段,我可以使用 where 条件获取数据,但是当我尝试对时间戳字段和日期执行相同操作时,事情不起作用。
这是我的代码:
home.ts
firebase.firestore().collection("cities").where("timestamp", ">", "3/24/2020")
.onSnapshot(function(querySnapshot) {
var cities = [];
querySnapshot.forEach(function(doc) {
cities.push(doc.data().name);
});
console.log("Timestamp greather than 3/24/2020 -- ", cities.join(", "));
});
一切正常firebase.firestore().collection("cities").where("state", "==", "CA")
但不与date
.
火库截图:
Note: JLD
doc 应该在控制台中返回,因为它timestamp
值大于3/24/2020
Edit 1
在@alex的指导下,我现在正在这样做
let start = new Date('2020-03-25');
firebase.firestore().collection("cities").where("timestamp", ">", start)
但它包括的数据2020-03-25
当我使用时>
, why ?